Commit | Line | Data |
---|---|---|
36db1edd ML |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2009 Eric Wong, Mark Lodato | |
4 | # | |
5 | ||
6 | test_description='git svn authors prog tests' | |
7 | ||
8 | . ./lib-git-svn.sh | |
9 | ||
01730a3b JM |
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"; | |
16 | } | |
36db1edd | 17 | EOF |
36db1edd | 18 | |
01730a3b JM |
19 | test_expect_success 'svn-authors setup' ' |
20 | cat >svn-authors <<-\EOF | |
21 | ff = FFFFFFF FFFFFFF <fFf@other.example.com> | |
22 | EOF | |
23 | ' | |
36db1edd ML |
24 | |
25 | test_expect_success 'setup svnrepo' ' | |
26 | for i in aa bb cc-sub dd-sub ee-foo ff | |
27 | do | |
28 | svn mkdir -m $i --username $i "$svnrepo"/$i | |
29 | done | |
01730a3b | 30 | ' |
36db1edd ML |
31 | |
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 | |
01730a3b | 35 | ' |
36db1edd ML |
36 | |
37 | test_expect_success 'imported 6 revisions successfully' ' | |
38 | ( | |
39 | cd x | |
27fe43e8 | 40 | test "$(git rev-list refs/remotes/git-svn | wc -l)" -eq 6 |
36db1edd | 41 | ) |
01730a3b | 42 | ' |
36db1edd ML |
43 | |
44 | test_expect_success 'authors-prog ran correctly' ' | |
45 | ( | |
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> " | |
57 | ) | |
01730a3b | 58 | ' |
36db1edd ML |
59 | |
60 | test_expect_success 'authors-file overrode authors-prog' ' | |
61 | ( | |
62 | cd x | |
63 | git rev-list -1 --pretty=raw refs/remotes/git-svn | \ | |
64 | grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> " | |
65 | ) | |
01730a3b | 66 | ' |
36db1edd | 67 | |
d3d7d47e ML |
68 | git --git-dir=x/.git config --unset svn.authorsfile |
69 | git --git-dir=x/.git config --unset svn.authorsprog | |
70 | ||
71 | test_expect_success 'authors-prog handled special characters in username' ' | |
72 | svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad && | |
73 | ( | |
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 | |
79 | ) | |
80 | ' | |
81 | ||
36db1edd | 82 | test_done |