Skip to content

Commit 9da781b

Browse files
Vampiretnyblom
authored andcommitted
Add some tests for empty-dirs parameter
1 parent 34c2d55 commit 9da781b

File tree

1 file changed

+173
-0
lines changed

1 file changed

+173
-0
lines changed

test/empty-dirs.bats

+173
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
load 'common'
2+
3+
@test 'empty-dirs parameter should put empty .gitignore files to empty directories' {
4+
svn mkdir dir-a
5+
svn commit -m 'add dir-a'
6+
7+
cd "$TEST_TEMP_DIR"
8+
svn2git "$SVN_REPO" --empty-dirs --rules <(echo "
9+
create repository git-repo
10+
end repository
11+
12+
match /
13+
repository git-repo
14+
branch master
15+
end match
16+
")
17+
18+
assert git -C git-repo show master:dir-a/.gitignore
19+
assert_equal "$(git -C git-repo show master:dir-a/.gitignore)" ''
20+
}
21+
22+
@test 'empty-dirs parameter should put empty .gitignore files to empty directories (nested)' {
23+
svn mkdir project-a
24+
cd project-a
25+
svn mkdir dir-a
26+
svn commit -m 'add dir-a'
27+
28+
cd "$TEST_TEMP_DIR"
29+
svn2git "$SVN_REPO" --empty-dirs --rules <(echo "
30+
create repository git-repo
31+
end repository
32+
33+
match /project-a/
34+
repository git-repo
35+
branch master
36+
end match
37+
")
38+
39+
assert git -C git-repo show master:dir-a/.gitignore
40+
assert_equal "$(git -C git-repo show master:dir-a/.gitignore)" ''
41+
}
42+
43+
@test 'empty-dirs parameter should not put empty .gitignore files to non-empty directories' {
44+
svn mkdir dir-a
45+
touch dir-a/file-a
46+
svn add dir-a/file-a
47+
svn commit -m 'add dir-a/file-a'
48+
49+
cd "$TEST_TEMP_DIR"
50+
svn2git "$SVN_REPO" --empty-dirs --rules <(echo "
51+
create repository git-repo
52+
end repository
53+
54+
match /
55+
repository git-repo
56+
branch master
57+
end match
58+
")
59+
60+
refute git -C git-repo show master:dir-a/.gitignore
61+
}
62+
63+
@test 'empty-dirs parameter should not put empty .gitignore files to non-empty directories (nested)' {
64+
svn mkdir project-a
65+
cd project-a
66+
svn mkdir dir-a
67+
touch dir-a/file-a
68+
svn add dir-a/file-a
69+
svn commit -m 'add dir-a/file-a'
70+
71+
cd "$TEST_TEMP_DIR"
72+
svn2git "$SVN_REPO" --empty-dirs --rules <(echo "
73+
create repository git-repo
74+
end repository
75+
76+
match /project-a/
77+
repository git-repo
78+
branch master
79+
end match
80+
")
81+
82+
refute git -C git-repo show master:dir-a/.gitignore
83+
}
84+
85+
@test 'empty-dirs parameter should not put empty .gitignore files to directories with generated .gitignore' {
86+
svn mkdir dir-a
87+
svn propset svn:ignore $'ignore-a\nignore-b' dir-a
88+
svn commit -m 'add dir-a with ignores'
89+
90+
cd "$TEST_TEMP_DIR"
91+
svn2git "$SVN_REPO" --svn-ignore --empty-dirs --rules <(echo "
92+
create repository git-repo
93+
end repository
94+
95+
match /
96+
repository git-repo
97+
branch master
98+
end match
99+
")
100+
101+
assert_equal "$(git -C git-repo show master:dir-a/.gitignore)" "$(cat <<-EOF
102+
/ignore-a
103+
/ignore-b
104+
EOF
105+
)"
106+
}
107+
108+
@test 'empty-dirs parameter should not put empty .gitignore files to directories with generated .gitignore (nested)' {
109+
svn mkdir project-a
110+
cd project-a
111+
svn mkdir dir-a
112+
svn propset svn:ignore $'ignore-a\nignore-b' dir-a
113+
svn commit -m 'add dir-a with ignores'
114+
115+
cd "$TEST_TEMP_DIR"
116+
svn2git "$SVN_REPO" --svn-ignore --empty-dirs --rules <(echo "
117+
create repository git-repo
118+
end repository
119+
120+
match /project-a/
121+
repository git-repo
122+
branch master
123+
end match
124+
")
125+
126+
assert_equal "$(git -C git-repo show master:dir-a/.gitignore)" "$(cat <<-EOF
127+
/ignore-a
128+
/ignore-b
129+
EOF
130+
)"
131+
}
132+
133+
@test 'empty-dirs parameter should not put empty .gitignore files to directories with .gitignore' {
134+
svn mkdir dir-a
135+
echo ignore-a >dir-a/.gitignore
136+
svn add dir-a/.gitignore
137+
svn commit -m 'add dir-a/.gitignore'
138+
139+
cd "$TEST_TEMP_DIR"
140+
svn2git "$SVN_REPO" --empty-dirs --rules <(echo "
141+
create repository git-repo
142+
end repository
143+
144+
match /
145+
repository git-repo
146+
branch master
147+
end match
148+
")
149+
150+
assert_equal "$(git -C git-repo show master:dir-a/.gitignore)" 'ignore-a'
151+
}
152+
153+
@test 'empty-dirs parameter should not put empty .gitignore files to directories with .gitignore (nested)' {
154+
svn mkdir project-a
155+
cd project-a
156+
svn mkdir dir-a
157+
echo ignore-a >dir-a/.gitignore
158+
svn add dir-a/.gitignore
159+
svn commit -m 'add dir-a/.gitignore'
160+
161+
cd "$TEST_TEMP_DIR"
162+
svn2git "$SVN_REPO" --empty-dirs --rules <(echo "
163+
create repository git-repo
164+
end repository
165+
166+
match /project-a/
167+
repository git-repo
168+
branch master
169+
end match
170+
")
171+
172+
assert_equal "$(git -C git-repo show master:dir-a/.gitignore)" 'ignore-a'
173+
}

0 commit comments

Comments
 (0)