Brad King | 128de65 | 2008-07-25 11:32:37 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2008 Brad King |
| 4 | |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 5 | test_description='git svn dcommit honors auto-props' |
Brad King | 128de65 | 2008-07-25 11:32:37 -0400 | [diff] [blame] | 6 | |
| 7 | . ./lib-git-svn.sh |
| 8 | |
| 9 | generate_auto_props() { |
| 10 | cat << EOF |
| 11 | [miscellany] |
| 12 | enable-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 |
| 16 | EOF |
| 17 | } |
| 18 | |
Nanako Shiraishi | f964732 | 2008-09-10 06:25:27 +0900 | [diff] [blame] | 19 | test_expect_success 'initialize git svn' ' |
Brad King | 128de65 | 2008-07-25 11:32:37 -0400 | [diff] [blame] | 20 | mkdir import && |
| 21 | ( |
| 22 | cd import && |
| 23 | echo foo >foo && |
Nanako Shiraishi | f964732 | 2008-09-10 06:25:27 +0900 | [diff] [blame] | 24 | svn import -m "import for git svn" . "$svnrepo" |
Brad King | 128de65 | 2008-07-25 11:32:37 -0400 | [diff] [blame] | 25 | ) && |
| 26 | rm -rf import && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 27 | git svn init "$svnrepo" |
| 28 | git svn fetch |
Brad King | 128de65 | 2008-07-25 11:32:37 -0400 | [diff] [blame] | 29 | ' |
| 30 | |
| 31 | test_expect_success 'enable auto-props config' ' |
Brad King | 128de65 | 2008-07-25 11:32:37 -0400 | [diff] [blame] | 32 | mkdir user && |
| 33 | generate_auto_props yes >user/config |
| 34 | ' |
| 35 | |
| 36 | test_expect_success 'add files matching auto-props' ' |
Brad King | 128de65 | 2008-07-25 11:32:37 -0400 | [diff] [blame] | 37 | echo "#!$SHELL_PATH" >exec1.sh && |
| 38 | chmod +x exec1.sh && |
| 39 | echo "hello" >hello.txt && |
| 40 | echo bar >bar && |
| 41 | git add exec1.sh hello.txt bar && |
| 42 | git commit -m "files for enabled auto-props" && |
| 43 | git svn dcommit --config-dir=user |
| 44 | ' |
| 45 | |
| 46 | test_expect_success 'disable auto-props config' ' |
Brad King | 128de65 | 2008-07-25 11:32:37 -0400 | [diff] [blame] | 47 | generate_auto_props no >user/config |
| 48 | ' |
| 49 | |
| 50 | test_expect_success 'add files matching disabled auto-props' ' |
Brad King | 128de65 | 2008-07-25 11:32:37 -0400 | [diff] [blame] | 51 | echo "#$SHELL_PATH" >exec2.sh && |
| 52 | chmod +x exec2.sh && |
| 53 | echo "world" >world.txt && |
| 54 | echo zot >zot && |
| 55 | git add exec2.sh world.txt zot && |
| 56 | git commit -m "files for disabled auto-props" && |
| 57 | git svn dcommit --config-dir=user |
| 58 | ' |
| 59 | |
| 60 | test_expect_success 'check resulting svn repository' ' |
Eric Wong | a786091 | 2008-09-06 18:29:12 -0700 | [diff] [blame] | 61 | ( |
Brad King | 128de65 | 2008-07-25 11:32:37 -0400 | [diff] [blame] | 62 | mkdir work && |
| 63 | cd work && |
| 64 | svn co "$svnrepo" && |
| 65 | cd svnrepo && |
| 66 | |
| 67 | # Check properties from first commit. |
| 68 | test "x$(svn propget svn:executable exec1.sh)" = "x*" && |
| 69 | test "x$(svn propget svn:mime-type exec1.sh)" = \ |
| 70 | "xapplication/x-shellscript" && |
| 71 | test "x$(svn propget svn:mime-type hello.txt)" = "xtext/plain" && |
| 72 | test "x$(svn propget svn:eol-style hello.txt)" = "xnative" && |
| 73 | test "x$(svn propget svn:mime-type bar)" = "x" && |
| 74 | |
| 75 | # Check properties from second commit. |
| 76 | test "x$(svn propget svn:executable exec2.sh)" = "x*" && |
| 77 | test "x$(svn propget svn:mime-type exec2.sh)" = "x" && |
| 78 | test "x$(svn propget svn:mime-type world.txt)" = "x" && |
| 79 | test "x$(svn propget svn:eol-style world.txt)" = "x" && |
| 80 | test "x$(svn propget svn:mime-type zot)" = "x" |
Eric Wong | a786091 | 2008-09-06 18:29:12 -0700 | [diff] [blame] | 81 | ) |
Brad King | 128de65 | 2008-07-25 11:32:37 -0400 | [diff] [blame] | 82 | ' |
| 83 | |
Paul Talacko | 7c4d021 | 2008-09-06 18:50:38 -0700 | [diff] [blame] | 84 | test_expect_success 'check renamed file' ' |
| 85 | test -d user && |
| 86 | generate_auto_props yes > user/config && |
| 87 | git mv foo foo.sh && |
| 88 | git commit -m "foo => foo.sh" && |
| 89 | git svn dcommit --config-dir=user && |
| 90 | ( |
| 91 | cd work/svnrepo && |
| 92 | svn up && |
| 93 | test ! -e foo && |
| 94 | test -e foo.sh && |
| 95 | test "x$(svn propget svn:mime-type foo.sh)" = \ |
| 96 | "xapplication/x-shellscript" && |
| 97 | test "x$(svn propget svn:eol-style foo.sh)" = "xLF" |
| 98 | ) |
| 99 | ' |
| 100 | |
Brad King | 128de65 | 2008-07-25 11:32:37 -0400 | [diff] [blame] | 101 | test_done |