The eleventh batch
[git/gitster.git] / t / t9138-git-svn-authors-prog.sh
blob784ec7fc2d6e4d22feaad6dfc17120e24856b407
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/-hermit//) {
13 print "$_ <>\n";
14 } elsif (s/-sub$//) {
15 print "$_ <$_\@sub.example.com>\n";
16 } else {
17 print "$_ <$_\@example.com>\n";
19 EOF
21 test_expect_success 'svn-authors setup' '
22 cat >svn-authors <<-\EOF
23 ff = FFFFFFF FFFFFFF <fFf@other.example.com>
24 EOF
27 test_expect_success 'setup svnrepo' '
28 for i in aa bb cc-sub dd-sub ee-foo ff
30 svn mkdir -m $i --username $i "$svnrepo"/$i || return 1
31 done
34 test_expect_success 'import authors with prog and file' '
35 git svn clone --authors-prog=./svn-authors-prog \
36 --authors-file=svn-authors "$svnrepo" x
39 test_expect_success 'imported 6 revisions successfully' '
41 cd x &&
42 git rev-list refs/remotes/git-svn >actual &&
43 test_line_count = 6 actual
47 test_expect_success 'authors-prog ran correctly' '
49 cd x &&
50 git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual &&
51 grep "^author ee-foo <ee-foo@example\.com> " actual &&
52 git rev-list -1 --pretty=raw refs/remotes/git-svn~2 >actual &&
53 grep "^author dd <dd@sub\.example\.com> " actual &&
54 git rev-list -1 --pretty=raw refs/remotes/git-svn~3 >actual &&
55 grep "^author cc <cc@sub\.example\.com> " actual &&
56 git rev-list -1 --pretty=raw refs/remotes/git-svn~4 >actual &&
57 grep "^author bb <bb@example\.com> " actual &&
58 git rev-list -1 --pretty=raw refs/remotes/git-svn~5 >actual &&
59 grep "^author aa <aa@example\.com> " actual
63 test_expect_success 'authors-file overrode authors-prog' '
65 cd x &&
66 git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
67 grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> " actual
71 git --git-dir=x/.git config --unset svn.authorsfile
72 git --git-dir=x/.git config --unset svn.authorsprog
74 test_expect_success 'authors-prog imported user without email' '
75 svn mkdir -m gg --username gg-hermit "$svnrepo"/gg &&
77 cd x &&
78 git svn fetch --authors-prog=../svn-authors-prog &&
79 git rev-list -1 --pretty=raw refs/remotes/git-svn | \
80 grep "^author gg <> "
84 test_expect_success 'imported without authors-prog and authors-file' '
85 svn mkdir -m hh --username hh "$svnrepo"/hh &&
87 uuid=$(svn info "$svnrepo" |
88 sed -n "s/^Repository UUID: //p") &&
89 cd x &&
90 git svn fetch &&
91 git rev-list -1 --pretty=raw refs/remotes/git-svn | \
92 grep "^author hh <hh@$uuid> "
96 test_expect_success 'authors-prog handled special characters in username' '
97 svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad &&
99 cd x &&
100 git svn --authors-prog=../svn-authors-prog fetch &&
101 git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
102 grep "^author xyz; touch evil <xyz; touch evil@example\.com> " actual &&
103 ! test -f evil
107 test_done