Mark Lodato | 36db1ed | 2009-05-14 21:27:15 -0400 | [diff] [blame] | 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 | |
| 10 | cat > svn-authors-prog <<'EOF' |
| 11 | #!/usr/bin/perl |
| 12 | $_ = shift; |
| 13 | if (s/-sub$//) { |
| 14 | print "$_ <$_\@sub.example.com>\n"; |
| 15 | } |
| 16 | else { |
| 17 | print "$_ <$_\@example.com>\n"; |
| 18 | } |
| 19 | EOF |
| 20 | chmod +x svn-authors-prog |
| 21 | |
| 22 | cat > svn-authors <<'EOF' |
| 23 | ff = FFFFFFF FFFFFFF <fFf@other.example.com> |
| 24 | EOF |
| 25 | |
| 26 | test_expect_success 'setup svnrepo' ' |
| 27 | for i in aa bb cc-sub dd-sub ee-foo ff |
| 28 | do |
| 29 | svn mkdir -m $i --username $i "$svnrepo"/$i |
| 30 | done |
| 31 | ' |
| 32 | |
| 33 | test_expect_success 'import authors with prog and file' ' |
| 34 | git svn clone --authors-prog=./svn-authors-prog \ |
| 35 | --authors-file=svn-authors "$svnrepo" x |
| 36 | ' |
| 37 | |
| 38 | test_expect_success 'imported 6 revisions successfully' ' |
| 39 | ( |
| 40 | cd x |
| 41 | test "`git rev-list refs/remotes/git-svn | wc -l`" -eq 6 |
| 42 | ) |
| 43 | ' |
| 44 | |
| 45 | test_expect_success 'authors-prog ran correctly' ' |
| 46 | ( |
| 47 | cd x |
| 48 | git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \ |
| 49 | grep "^author ee-foo <ee-foo@example\.com> " && |
| 50 | git rev-list -1 --pretty=raw refs/remotes/git-svn~2 | \ |
| 51 | grep "^author dd <dd@sub\.example\.com> " && |
| 52 | git rev-list -1 --pretty=raw refs/remotes/git-svn~3 | \ |
| 53 | grep "^author cc <cc@sub\.example\.com> " && |
| 54 | git rev-list -1 --pretty=raw refs/remotes/git-svn~4 | \ |
| 55 | grep "^author bb <bb@example\.com> " && |
| 56 | git rev-list -1 --pretty=raw refs/remotes/git-svn~5 | \ |
| 57 | grep "^author aa <aa@example\.com> " |
| 58 | ) |
| 59 | ' |
| 60 | |
| 61 | test_expect_success 'authors-file overrode authors-prog' ' |
| 62 | ( |
| 63 | cd x |
| 64 | git rev-list -1 --pretty=raw refs/remotes/git-svn | \ |
| 65 | grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> " |
| 66 | ) |
| 67 | ' |
| 68 | |
Mark Lodato | d3d7d47 | 2009-09-12 20:33:23 -0400 | [diff] [blame] | 69 | git --git-dir=x/.git config --unset svn.authorsfile |
| 70 | git --git-dir=x/.git config --unset svn.authorsprog |
| 71 | |
| 72 | test_expect_success 'authors-prog handled special characters in username' ' |
| 73 | svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad && |
| 74 | ( |
| 75 | cd x && |
| 76 | git svn --authors-prog=../svn-authors-prog fetch && |
| 77 | git rev-list -1 --pretty=raw refs/remotes/git-svn | |
| 78 | grep "^author xyz; touch evil <xyz; touch evil@example\.com> " && |
| 79 | ! test -f evil |
| 80 | ) |
| 81 | ' |
| 82 | |
Mark Lodato | 36db1ed | 2009-05-14 21:27:15 -0400 | [diff] [blame] | 83 | test_done |