t / t9138-git-svn-authors-prog.shon commit test: avoid pipes in git related commands for test (a4d4e32)
   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                git rev-list refs/remotes/git-svn >actual &&
  41                test_line_count = 6 actual
  42        )
  43'
  44
  45test_expect_success 'authors-prog ran correctly' '
  46        (
  47                cd x
  48                git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual &&
  49                grep "^author ee-foo <ee-foo@example\.com> " actual &&
  50                git rev-list -1 --pretty=raw refs/remotes/git-svn~2 >actual &&
  51                grep "^author dd <dd@sub\.example\.com> " actual &&
  52                git rev-list -1 --pretty=raw refs/remotes/git-svn~3 >actual &&
  53                grep "^author cc <cc@sub\.example\.com> " actual &&
  54                git rev-list -1 --pretty=raw refs/remotes/git-svn~4 >actual &&
  55                grep "^author bb <bb@example\.com> " actual &&
  56                git rev-list -1 --pretty=raw refs/remotes/git-svn~5 >actual &&
  57                grep "^author aa <aa@example\.com> " actual
  58        )
  59'
  60
  61test_expect_success 'authors-file overrode authors-prog' '
  62        (
  63                cd x
  64                git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
  65                grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> " actual
  66        )
  67'
  68
  69git --git-dir=x/.git config --unset svn.authorsfile
  70git --git-dir=x/.git config --unset svn.authorsprog
  71
  72test_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 >actual &&
  78                grep "^author xyz; touch evil <xyz; touch evil@example\.com> " actual &&
  79                ! test -f evil
  80        )
  81'
  82
  83test_done