t / t9124-git-svn-dcommit-auto-props.shon commit Merge branch 'rs/submodule-config-code-cleanup' (f4fa8a9)
   1#!/bin/sh
   2#
   3# Copyright (c) 2008 Brad King
   4
   5test_description='git svn dcommit honors auto-props'
   6
   7. ./lib-git-svn.sh
   8
   9generate_auto_props() {
  10cat << EOF
  11[miscellany]
  12enable-auto-props=$1
  13[auto-props]
  14*.sh  = svn:mime-type=application/x-shellscript; svn:eol-style=LF
  15*.txt = svn:mime-type=text/plain; svn:eol-style = native
  16EOF
  17}
  18
  19test_expect_success 'initialize git svn' '
  20        mkdir import &&
  21        (
  22                cd import &&
  23                echo foo >foo &&
  24                svn_cmd import -m "import for git svn" . "$svnrepo"
  25        ) &&
  26        rm -rf import &&
  27        git svn init "$svnrepo" &&
  28        git svn fetch
  29'
  30
  31test_expect_success 'enable auto-props config' '
  32        mkdir user &&
  33        generate_auto_props yes >user/config
  34'
  35
  36test_expect_success 'add files matching auto-props' '
  37        write_script exec1.sh </dev/null &&
  38        echo "hello" >hello.txt &&
  39        echo bar >bar &&
  40        git add exec1.sh hello.txt bar &&
  41        git commit -m "files for enabled auto-props" &&
  42        git svn dcommit --config-dir=user
  43'
  44
  45test_expect_success 'disable auto-props config' '
  46        generate_auto_props no >user/config
  47'
  48
  49test_expect_success 'add files matching disabled auto-props' '
  50        write_script exec2.sh </dev/null &&
  51        echo "world" >world.txt &&
  52        echo zot >zot &&
  53        git add exec2.sh world.txt zot &&
  54        git commit -m "files for disabled auto-props" &&
  55        git svn dcommit --config-dir=user
  56'
  57
  58test_expect_success 'check resulting svn repository' '
  59(
  60        mkdir work &&
  61        cd work &&
  62        svn_cmd co "$svnrepo" &&
  63        cd svnrepo &&
  64
  65        # Check properties from first commit.
  66        if test_have_prereq POSIXPERM
  67        then
  68                test "x$(svn_cmd propget svn:executable exec1.sh)" = "x*"
  69        fi &&
  70        test "x$(svn_cmd propget svn:mime-type exec1.sh)" = \
  71             "xapplication/x-shellscript" &&
  72        test "x$(svn_cmd propget svn:mime-type hello.txt)" = "xtext/plain" &&
  73        test "x$(svn_cmd propget svn:eol-style hello.txt)" = "xnative" &&
  74        test "x$(svn_cmd propget svn:mime-type bar)" = "x" &&
  75
  76        # Check properties from second commit.
  77        if test_have_prereq POSIXPERM
  78        then
  79                test "x$(svn_cmd propget svn:executable exec2.sh)" = "x*"
  80        fi &&
  81        test "x$(svn_cmd propget svn:mime-type exec2.sh)" = "x" &&
  82        test "x$(svn_cmd propget svn:mime-type world.txt)" = "x" &&
  83        test "x$(svn_cmd propget svn:eol-style world.txt)" = "x" &&
  84        test "x$(svn_cmd propget svn:mime-type zot)" = "x"
  85)
  86'
  87
  88test_expect_success 'check renamed file' '
  89        test -d user &&
  90        generate_auto_props yes > user/config &&
  91        git mv foo foo.sh &&
  92        git commit -m "foo => foo.sh" &&
  93        git svn dcommit --config-dir=user &&
  94        (
  95                cd work/svnrepo &&
  96                svn_cmd up &&
  97                test ! -e foo &&
  98                test -e foo.sh &&
  99                test "x$(svn_cmd propget svn:mime-type foo.sh)" = \
 100                     "xapplication/x-shellscript" &&
 101                test "x$(svn_cmd propget svn:eol-style foo.sh)" = "xLF"
 102        )
 103'
 104
 105test_done