t3420: fix under GETTEXT_POISON build
[git/debian.git] / t / t9138-git-svn-authors-prog.sh
blob7d7e9d46bc6bf40f52efffede6b369f052c46843
1 #!/bin/sh
3 # Copyright (c) 2009 Eric Wong, Mark Lodato
6 test_description='git svn authors prog tests'
8 . ./lib-git-svn.sh
10 write_script svn-authors-prog "$PERL_PATH" <<-\EOF
11 $_ = shift;
12 if (s/-sub$//) {
13 print "$_ <$_\@sub.example.com>\n";
14 } else {
15 print "$_ <$_\@example.com>\n";
17 EOF
19 test_expect_success 'svn-authors setup' '
20 cat >svn-authors <<-\EOF
21 ff = FFFFFFF FFFFFFF <fFf@other.example.com>
22 EOF
25 test_expect_success 'setup svnrepo' '
26 for i in aa bb cc-sub dd-sub ee-foo ff
28 svn mkdir -m $i --username $i "$svnrepo"/$i
29 done
32 test_expect_success 'import authors with prog and file' '
33 git svn clone --authors-prog=./svn-authors-prog \
34 --authors-file=svn-authors "$svnrepo" x
37 test_expect_success 'imported 6 revisions successfully' '
39 cd x
40 test "$(git rev-list refs/remotes/git-svn | wc -l)" -eq 6
44 test_expect_success 'authors-prog ran correctly' '
46 cd x
47 git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \
48 grep "^author ee-foo <ee-foo@example\.com> " &&
49 git rev-list -1 --pretty=raw refs/remotes/git-svn~2 | \
50 grep "^author dd <dd@sub\.example\.com> " &&
51 git rev-list -1 --pretty=raw refs/remotes/git-svn~3 | \
52 grep "^author cc <cc@sub\.example\.com> " &&
53 git rev-list -1 --pretty=raw refs/remotes/git-svn~4 | \
54 grep "^author bb <bb@example\.com> " &&
55 git rev-list -1 --pretty=raw refs/remotes/git-svn~5 | \
56 grep "^author aa <aa@example\.com> "
60 test_expect_success 'authors-file overrode authors-prog' '
62 cd x
63 git rev-list -1 --pretty=raw refs/remotes/git-svn | \
64 grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> "
68 git --git-dir=x/.git config --unset svn.authorsfile
69 git --git-dir=x/.git config --unset svn.authorsprog
71 test_expect_success 'authors-prog handled special characters in username' '
72 svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad &&
74 cd x &&
75 git svn --authors-prog=../svn-authors-prog fetch &&
76 git rev-list -1 --pretty=raw refs/remotes/git-svn |
77 grep "^author xyz; touch evil <xyz; touch evil@example\.com> " &&
78 ! test -f evil
82 test_done