t / t9138-git-svn-authors-prog.shon commit Merge branch 'jk/ident-ai-canonname-could-be-null' into maint (11738dd)
   1#!/bin/sh
   2#
   3# Copyright (c) 2009 Eric Wong, Mark Lodato
   4#
   5
   6test_description='git svn authors prog tests'
   7
   8. ./lib-git-svn.sh
   9
  10write_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        }
  17EOF
  18
  19test_expect_success 'svn-authors setup' '
  20        cat >svn-authors <<-\EOF
  21        ff = FFFFFFF FFFFFFF <fFf@other.example.com>
  22        EOF
  23'
  24
  25test_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
  30'
  31
  32test_expect_success 'import authors with prog and file' '
  33        git svn clone --authors-prog=./svn-authors-prog \
  34            --authors-file=svn-authors "$svnrepo" x
  35'
  36
  37test_expect_success 'imported 6 revisions successfully' '
  38        (
  39                cd x
  40                test "$(git rev-list refs/remotes/git-svn | wc -l)" -eq 6
  41        )
  42'
  43
  44test_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        )
  58'
  59
  60test_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        )
  66'
  67
  68git --git-dir=x/.git config --unset svn.authorsfile
  69git --git-dir=x/.git config --unset svn.authorsprog
  70
  71test_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
  82test_done