#! /bin/sh

D=$(cd $(dirname "$0") && pwd)
cd "$D" || exit 1
. ./helper-functions.sh || exit 1
T="$D/test-repo.git"
DUMPFILE="$D/test-repo.dump"

test -d "$T" && rm -rf "$T"
git init --bare "$T" >/dev/null
GIT_DIR="$T"
export GIT_DIR

git fast-import <"$DUMPFILE" 2>/dev/null

git config user.name 'Joe User'
git config user.email 'user@example.com'

git config multimailhook.environment 'generic'
git config multimailhook.reponame 'test-repo'

git config multimailhook.mailinglist 'Mailing List <mailinglist@example.com>'
git config multimailhook.refchangelist 'Refchange List <refchangelist@example.com>'
git config multimailhook.announcelist 'Announce List <announcelist@example.com>, Zébulon <zeb@example.com>'
git config multimailhook.commitlist 'Commit List <commitlist@example.com>'

git config multimailhook.announceshortlog 'true'
git config multimailhook.envelopesender 'Sender <sender@example.com>'
git config multimailhook.from 'From <from@example.com>'
git config multimailhook.administrator 'Administrator <administrator@example.com>'

git config multimailhook.emailprefix '*test-repo*'
git config multimailhook.emaildomain 'example.com'

# Configure a fake sendmail program that just writes to stdout:
git config multimailhook.mailer "sendmail"
git config multimailhook.sendmailcommand "$D/fake-sendmail -oi -t"

# Create some bizarre tags that git-fast-export cannot handle:
GIT_COMMITTER_DATE="2012-11-22 02:00 +0530" \
git tag recursive-tag refs/tags/tag-annotated \
    -m 'This annotated tag points at another annotated tag.'

GIT_COMMITTER_DATE="2012-11-22 03:00 +0530" \
git tag tree tag: \
    -m 'This annotated tag points at a tree.'

GIT_COMMITTER_DATE="2012-11-22 04:00 +0530" \
git tag tree-tag tree \
    -m 'This annotated tag points at a tag that points at a tree.'

pecho "$T"
