4 # Charles Roussel <charles.roussel@ensimag.imag.fr>
5 # Simon Cathebras <simon.cathebras@ensimag.imag.fr>
6 # Julien Khayat <julien.khayat@ensimag.imag.fr>
7 # Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
8 # Simon Perrat <simon.perrat@ensimag.imag.fr>
10 # License: GPL v2 or later
13 test_description='Test the Git Mediawiki remote helper: git clone'
16 . $TEST_DIRECTORY/test-lib.sh
22 test_expect_success 'Git clone creates the expected git log with one file' '
24 wiki_editpage foo "this is not important" false -c cat -s "this must be the same" &&
25 git clone mediawiki::'"$WIKI_URL"' mw_dir_1 &&
28 git log --format=%s HEAD^..HEAD >log.tmp
30 echo "this must be the same" >msg.tmp &&
31 test_cmp msg.tmp mw_dir_1/log.tmp
35 test_expect_success 'Git clone creates the expected git log with multiple files' '
37 wiki_editpage daddy "this is not important" false -s="this must be the same" &&
38 wiki_editpage daddy "neither is this" true -s="this must also be the same" &&
39 wiki_editpage daddy "neither is this" true -s="same same same" &&
40 wiki_editpage dj "dont care" false -s="identical" &&
41 wiki_editpage dj "dont care either" true -s="identical too" &&
42 git clone mediawiki::'"$WIKI_URL"' mw_dir_2 &&
45 git log --format=%s Daddy.mw >logDaddy.tmp &&
46 git log --format=%s Dj.mw >logDj.tmp
48 echo "same same same" >msgDaddy.tmp &&
49 echo "this must also be the same" >>msgDaddy.tmp &&
50 echo "this must be the same" >>msgDaddy.tmp &&
51 echo "identical too" >msgDj.tmp &&
52 echo "identical" >>msgDj.tmp &&
53 test_cmp msgDaddy.tmp mw_dir_2/logDaddy.tmp &&
54 test_cmp msgDj.tmp mw_dir_2/logDj.tmp
58 test_expect_success 'Git clone creates only Main_Page.mw with an empty wiki' '
60 git clone mediawiki::'"$WIKI_URL"' mw_dir_3 &&
61 test_contains_N_files mw_dir_3 1 &&
62 test_path_is_file mw_dir_3/Main_Page.mw
65 test_expect_success 'Git clone does not fetch a deleted page' '
67 wiki_editpage foo "this page must be deleted before the clone" false &&
68 wiki_delete_page foo &&
69 git clone mediawiki::'"$WIKI_URL"' mw_dir_4 &&
70 test_contains_N_files mw_dir_4 1 &&
71 test_path_is_file mw_dir_4/Main_Page.mw &&
72 test_path_is_missing mw_dir_4/Foo.mw
75 test_expect_success 'Git clone works with page added' '
77 wiki_editpage foo " I will be cloned" false &&
78 wiki_editpage bar "I will be cloned" false &&
79 git clone mediawiki::'"$WIKI_URL"' mw_dir_5 &&
80 wiki_getallpage ref_page_5 &&
81 test_diff_directories mw_dir_5 ref_page_5 &&
82 wiki_delete_page foo &&
86 test_expect_success 'Git clone works with an edited page ' '
88 wiki_editpage foo "this page will be edited" \
89 false -s "first edition of page foo"&&
90 wiki_editpage foo "this page has been edited and must be on the clone " true &&
91 git clone mediawiki::'"$WIKI_URL"' mw_dir_6 &&
92 test_path_is_file mw_dir_6/Foo.mw &&
93 test_path_is_file mw_dir_6/Main_Page.mw &&
94 wiki_getallpage mw_dir_6/page_ref_6 &&
95 test_diff_directories mw_dir_6 mw_dir_6/page_ref_6 &&
98 git log --format=%s HEAD^ Foo.mw > ../Foo.log
100 echo "first edition of page foo" > FooExpect.log &&
101 diff FooExpect.log Foo.log
105 test_expect_success 'Git clone works with several pages and some deleted ' '
107 wiki_editpage foo "this page will not be deleted" false &&
108 wiki_editpage bar "I must not be erased" false &&
109 wiki_editpage namnam "I will not be there at the end" false &&
110 wiki_editpage nyancat "nyan nyan nyan delete me" false &&
111 wiki_delete_page namnam &&
112 wiki_delete_page nyancat &&
113 git clone mediawiki::'"$WIKI_URL"' mw_dir_7 &&
114 test_path_is_file mw_dir_7/Foo.mw &&
115 test_path_is_file mw_dir_7/Bar.mw &&
116 test_path_is_missing mw_dir_7/Namnam.mw &&
117 test_path_is_missing mw_dir_7/Nyancat.mw &&
118 wiki_getallpage mw_dir_7/page_ref_7 &&
119 test_diff_directories mw_dir_7 mw_dir_7/page_ref_7
123 test_expect_success 'Git clone works with one specific page cloned ' '
125 wiki_editpage foo "I will not be cloned" false &&
126 wiki_editpage bar "Do not clone me" false &&
127 wiki_editpage namnam "I will be cloned :)" false -s="this log must stay" &&
128 wiki_editpage nyancat "nyan nyan nyan you cant clone me" false &&
129 git clone -c remote.origin.pages=namnam \
130 mediawiki::'"$WIKI_URL"' mw_dir_8 &&
131 test_contains_N_files mw_dir_8 1 &&
132 test_path_is_file mw_dir_8/Namnam.mw &&
133 test_path_is_missing mw_dir_8/Main_Page.mw &&
136 echo "this log must stay" >msg.tmp &&
137 git log --format=%s >log.tmp &&
138 test_cmp msg.tmp log.tmp
140 wiki_check_content mw_dir_8/Namnam.mw Namnam
143 test_expect_success 'Git clone works with multiple specific page cloned ' '
145 wiki_editpage foo "I will be there" false &&
146 wiki_editpage bar "I will not disappear" false &&
147 wiki_editpage namnam "I be erased" false &&
148 wiki_editpage nyancat "nyan nyan nyan you will not erase me" false &&
149 wiki_delete_page namnam &&
150 git clone -c remote.origin.pages="foo bar nyancat namnam" \
151 mediawiki::'"$WIKI_URL"' mw_dir_9 &&
152 test_contains_N_files mw_dir_9 3 &&
153 test_path_is_missing mw_dir_9/Namnam.mw &&
154 test_path_is_file mw_dir_9/Foo.mw &&
155 test_path_is_file mw_dir_9/Nyancat.mw &&
156 test_path_is_file mw_dir_9/Bar.mw &&
157 wiki_check_content mw_dir_9/Foo.mw Foo &&
158 wiki_check_content mw_dir_9/Bar.mw Bar &&
159 wiki_check_content mw_dir_9/Nyancat.mw Nyancat
162 test_expect_success 'Mediawiki-clone of several specific pages on wiki' '
164 wiki_editpage foo "foo 1" false &&
165 wiki_editpage bar "bar 1" false &&
166 wiki_editpage dummy "dummy 1" false &&
167 wiki_editpage cloned_1 "cloned_1 1" false &&
168 wiki_editpage cloned_2 "cloned_2 2" false &&
169 wiki_editpage cloned_3 "cloned_3 3" false &&
170 mkdir -p ref_page_10 &&
171 wiki_getpage cloned_1 ref_page_10 &&
172 wiki_getpage cloned_2 ref_page_10 &&
173 wiki_getpage cloned_3 ref_page_10 &&
174 git clone -c remote.origin.pages="cloned_1 cloned_2 cloned_3" \
175 mediawiki::'"$WIKI_URL"' mw_dir_10 &&
176 test_diff_directories mw_dir_10 ref_page_10
179 test_expect_success 'Git clone works with the shallow option' '
181 wiki_editpage foo "1st revision, should be cloned" false &&
182 wiki_editpage bar "1st revision, should be cloned" false &&
183 wiki_editpage nyan "1st revision, should not be cloned" false &&
184 wiki_editpage nyan "2nd revision, should be cloned" false &&
185 git -c remote.origin.shallow=true clone \
186 mediawiki::'"$WIKI_URL"' mw_dir_11 &&
187 test_contains_N_files mw_dir_11 4 &&
188 test_path_is_file mw_dir_11/Nyan.mw &&
189 test_path_is_file mw_dir_11/Foo.mw &&
190 test_path_is_file mw_dir_11/Bar.mw &&
191 test_path_is_file mw_dir_11/Main_Page.mw &&
194 test $(git log --oneline Nyan.mw | wc -l) -eq 1 &&
195 test $(git log --oneline Foo.mw | wc -l) -eq 1 &&
196 test $(git log --oneline Bar.mw | wc -l) -eq 1 &&
197 test $(git log --oneline Main_Page.mw | wc -l ) -eq 1
199 wiki_check_content mw_dir_11/Nyan.mw Nyan &&
200 wiki_check_content mw_dir_11/Foo.mw Foo &&
201 wiki_check_content mw_dir_11/Bar.mw Bar &&
202 wiki_check_content mw_dir_11/Main_Page.mw Main_Page
205 test_expect_success 'Git clone works with the shallow option with a delete page' '
207 wiki_editpage foo "1st revision, will be deleted" false &&
208 wiki_editpage bar "1st revision, should be cloned" false &&
209 wiki_editpage nyan "1st revision, should not be cloned" false &&
210 wiki_editpage nyan "2nd revision, should be cloned" false &&
211 wiki_delete_page foo &&
212 git -c remote.origin.shallow=true clone \
213 mediawiki::'"$WIKI_URL"' mw_dir_12 &&
214 test_contains_N_files mw_dir_12 3 &&
215 test_path_is_file mw_dir_12/Nyan.mw &&
216 test_path_is_missing mw_dir_12/Foo.mw &&
217 test_path_is_file mw_dir_12/Bar.mw &&
218 test_path_is_file mw_dir_12/Main_Page.mw &&
221 test $(git log --oneline Nyan.mw | wc -l) -eq 1 &&
222 test $(git log --oneline Bar.mw | wc -l) -eq 1 &&
223 test $(git log --oneline Main_Page.mw | wc -l ) -eq 1
225 wiki_check_content mw_dir_12/Nyan.mw Nyan &&
226 wiki_check_content mw_dir_12/Bar.mw Bar &&
227 wiki_check_content mw_dir_12/Main_Page.mw Main_Page
230 test_expect_success 'Test of fetching a category' '
232 wiki_editpage Foo "I will be cloned" false -c=Category &&
233 wiki_editpage Bar "Meet me on the repository" false -c=Category &&
234 wiki_editpage Dummy "I will not come" false &&
235 wiki_editpage BarWrong "I will stay online only" false -c=NotCategory &&
236 git clone -c remote.origin.categories="Category" \
237 mediawiki::'"$WIKI_URL"' mw_dir_13 &&
238 wiki_getallpage ref_page_13 Category &&
239 test_diff_directories mw_dir_13 ref_page_13
242 test_expect_success 'Test of resistance to modification of category on wiki for clone' '
244 wiki_editpage Tobedeleted "this page will be deleted" false -c=Catone &&
245 wiki_editpage Tobeedited "this page will be modified" false -c=Catone &&
246 wiki_editpage Normalone "this page wont be modified and will be on git" false -c=Catone &&
247 wiki_editpage Notconsidered "this page will not appear on local" false &&
248 wiki_editpage Othercategory "this page will not appear on local" false -c=Cattwo &&
249 wiki_editpage Tobeedited "this page have been modified" true -c=Catone &&
250 wiki_delete_page Tobedeleted &&
251 git clone -c remote.origin.categories="Catone" \
252 mediawiki::'"$WIKI_URL"' mw_dir_14 &&
253 wiki_getallpage ref_page_14 Catone &&
254 test_diff_directories mw_dir_14 ref_page_14