t / t9130-git-svn-authors-file.shon commit Merge branch 'js/unmap-before-ext-diff' (d9beb46)
   1#!/bin/sh
   2#
   3# Copyright (c) 2008 Eric Wong
   4#
   5
   6test_description='git svn authors file tests'
   7
   8. ./lib-git-svn.sh
   9
  10cat > svn-authors <<EOF
  11aa = AAAAAAA AAAAAAA <aa@example.com>
  12bb = BBBBBBB BBBBBBB <bb@example.com>
  13EOF
  14
  15test_expect_success 'setup svnrepo' '
  16        for i in aa bb cc dd
  17        do
  18                svn_cmd mkdir -m $i --username $i "$svnrepo"/$i
  19        done
  20        '
  21
  22test_expect_success 'start import with incomplete authors file' '
  23        test_must_fail git svn clone --authors-file=svn-authors "$svnrepo" x
  24        '
  25
  26test_expect_success 'imported 2 revisions successfully' '
  27        (
  28                cd x &&
  29                git rev-list refs/remotes/git-svn >actual &&
  30                test_line_count = 2 actual &&
  31                git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
  32                grep "^author BBBBBBB BBBBBBB <bb@example\.com> " actual &&
  33                git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual &&
  34                grep "^author AAAAAAA AAAAAAA <aa@example\.com> " actual
  35        )
  36        '
  37
  38cat >> svn-authors <<EOF
  39cc = CCCCCCC CCCCCCC <cc@example.com>
  40dd = DDDDDDD DDDDDDD <dd@example.com>
  41EOF
  42
  43test_expect_success 'continues to import once authors have been added' '
  44        (
  45                cd x &&
  46                git svn fetch --authors-file=../svn-authors &&
  47                git rev-list refs/remotes/git-svn >actual &&
  48                test_line_count = 4 actual &&
  49                git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
  50                grep "^author DDDDDDD DDDDDDD <dd@example\.com> " actual &&
  51                git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual &&
  52                grep "^author CCCCCCC CCCCCCC <cc@example\.com> " actual
  53        )
  54        '
  55
  56test_expect_success 'authors-file against globs' '
  57        svn_cmd mkdir -m globs --username aa \
  58          "$svnrepo"/aa/trunk "$svnrepo"/aa/branches "$svnrepo"/aa/tags &&
  59        git svn clone --authors-file=svn-authors -s "$svnrepo"/aa aa-work &&
  60        for i in bb ee cc
  61        do
  62                branch="aa/branches/$i"
  63                svn_cmd mkdir -m "$branch" --username $i "$svnrepo/$branch"
  64        done
  65        '
  66
  67test_expect_success 'fetch fails on ee' '
  68        ( cd aa-work && test_must_fail git svn fetch --authors-file=../svn-authors )
  69        '
  70
  71tmp_config_get () {
  72        git config --file=.git/svn/.metadata --get "$1"
  73}
  74
  75test_expect_success 'failure happened without negative side effects' '
  76        (
  77                cd aa-work &&
  78                test 6 -eq "$(tmp_config_get svn-remote.svn.branches-maxRev)" &&
  79                test 6 -eq "$(tmp_config_get svn-remote.svn.tags-maxRev)"
  80        )
  81        '
  82
  83cat >> svn-authors <<EOF
  84ee = EEEEEEE EEEEEEE <ee@example.com>
  85EOF
  86
  87test_expect_success 'fetch continues after authors-file is fixed' '
  88        (
  89                cd aa-work &&
  90                git svn fetch --authors-file=../svn-authors &&
  91                test 8 -eq "$(tmp_config_get svn-remote.svn.branches-maxRev)" &&
  92                test 8 -eq "$(tmp_config_get svn-remote.svn.tags-maxRev)"
  93        )
  94        '
  95
  96test_expect_success !MINGW 'fresh clone with svn.authors-file in config' '
  97        (
  98                rm -r "$GIT_DIR" &&
  99                test x = x"$(git config svn.authorsfile)" &&
 100                test_config="$HOME"/.gitconfig &&
 101                sane_unset GIT_DIR &&
 102                git config --global \
 103                  svn.authorsfile "$HOME"/svn-authors &&
 104                test x"$HOME"/svn-authors = x"$(git config svn.authorsfile)" &&
 105                git svn clone "$svnrepo" gitconfig.clone &&
 106                cd gitconfig.clone &&
 107                git log >actual &&
 108                nr_ex=$(grep "^Author:.*example.com" actual | wc -l) &&
 109                git rev-list HEAD >actual &&
 110                nr_rev=$(wc -l <actual) &&
 111                test $nr_rev -eq $nr_ex
 112        )
 113'
 114
 115cat >> svn-authors <<EOF
 116ff = FFFFFFF FFFFFFF <>
 117EOF
 118
 119test_expect_success 'authors-file imported user without email' '
 120        svn_cmd mkdir -m aa/branches/ff --username ff "$svnrepo/aa/branches/ff" &&
 121        (
 122                cd aa-work &&
 123                git svn fetch --authors-file=../svn-authors &&
 124                git rev-list -1 --pretty=raw refs/remotes/origin/ff | \
 125                  grep "^author FFFFFFF FFFFFFF <> "
 126        )
 127        '
 128
 129test_debug 'GIT_DIR=gitconfig.clone/.git git log'
 130
 131test_done