1#!/bin/sh
2#
3# Copyright (c) 2014 Alfred Perlstein
4#
5
6test_description='git svn propset tests'
7
8. ./lib-git-svn.sh
9
10foo_subdir2="subdir/subdir2/foo_subdir2"
11
12set -e
13mkdir import &&
14(set -e ; cd import
15 mkdir subdir
16 mkdir subdir/subdir2
17 touch foo # for 'add props top level'
18 touch subdir/foo_subdir # for 'add props relative'
19 touch "$foo_subdir2" # for 'add props subdir'
20 svn_cmd import -m 'import for git svn' . "$svnrepo" >/dev/null
21)
22rm -rf import
23
24test_expect_success 'initialize git svn' '
25 git svn init "$svnrepo"
26 '
27
28test_expect_success 'fetch revisions from svn' '
29 git svn fetch
30 '
31
32set_props () {
33 subdir="$1"
34 file="$2"
35 shift;shift;
36 (cd "$subdir" &&
37 while [ $# -gt 0 ] ; do
38 git svn propset "$1" "$2" "$file" || exit 1
39 shift;shift;
40 done &&
41 echo hello >> "$file" &&
42 git commit -m "testing propset" "$file")
43}
44
45confirm_props () {
46 subdir="$1"
47 file="$2"
48 shift;shift;
49 (set -e ; cd "svn_project/$subdir" &&
50 while [ $# -gt 0 ] ; do
51 test "$(svn_cmd propget "$1" "$file")" = "$2" || exit 1
52 shift;shift;
53 done)
54}
55
56
57#The current implementation has a restriction:
58#svn propset will be taken as a delta for svn dcommit only
59#if the file content is also modified
60test_expect_success 'add props top level' '
61 set_props "." "foo" "svn:keywords" "FreeBSD=%H" &&
62 git svn dcommit &&
63 svn_cmd co "$svnrepo" svn_project &&
64 confirm_props "." "foo" "svn:keywords" "FreeBSD=%H" &&
65 rm -rf svn_project
66 '
67
68test_expect_success 'add multiple props' '
69 set_props "." "foo" \
70 "svn:keywords" "FreeBSD=%H" fbsd:nokeywords yes &&
71 git svn dcommit &&
72 svn_cmd co "$svnrepo" svn_project &&
73 confirm_props "." "foo" \
74 "svn:keywords" "FreeBSD=%H" fbsd:nokeywords yes &&
75 rm -rf svn_project
76 '
77
78test_expect_success 'add props subdir' '
79 set_props "." "$foo_subdir2" svn:keywords "FreeBSD=%H" &&
80 git svn dcommit &&
81 svn_cmd co "$svnrepo" svn_project &&
82 confirm_props "." "$foo_subdir2" "svn:keywords" "FreeBSD=%H" &&
83 rm -rf svn_project
84 '
85
86test_expect_success 'add props relative' '
87 set_props "subdir/subdir2" "../foo_subdir" \
88 svn:keywords "FreeBSD=%H" &&
89 git svn dcommit &&
90 svn_cmd co "$svnrepo" svn_project &&
91 confirm_props "subdir/subdir2" "../foo_subdir" \
92 svn:keywords "FreeBSD=%H" &&
93 rm -rf svn_project
94 '
95test_done