t / t9138-git-svn-authors-prog.shon commit Bigfile: teach "git add" to send a large file straight to a pack (4dd1fbc)
   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
  10cat > svn-authors-prog <<'EOF'
  11#!/usr/bin/perl
  12$_ = shift;
  13if (s/-sub$//)  {
  14        print "$_ <$_\@sub.example.com>\n";
  15}
  16else {
  17        print "$_ <$_\@example.com>\n";
  18}
  19EOF
  20chmod +x svn-authors-prog
  21
  22cat > svn-authors <<'EOF'
  23ff = FFFFFFF FFFFFFF <fFf@other.example.com>
  24EOF
  25
  26test_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
  33test_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
  38test_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
  45test_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
  61test_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
  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 |
  78                grep "^author xyz; touch evil <xyz; touch evil@example\.com> " &&
  79                ! test -f evil
  80        )
  81'
  82
  83test_done