Debian Codegraph @

t/t-push-failures-local.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 . "$(dirname "$0")/testlib.sh"
4
5 begin_test "push allow missing object (lfs.allowincompletepush true)"
6 (
7 set -e
8
9 reponame="push-allow-missing-object"
10 setup_remote_repo "$reponame"
11 clone_repo "$reponame" "$reponame"
12
13 git lfs track "*.dat"
14 git add .gitattributes
15 git commit -m "initial commit"
16
17 present="present"
18 present_oid="$(calc_oid "$present")"
19 printf "%s" "$present" > present.dat
20
21 missing="missing"
22 missing_oid="$(calc_oid "$missing")"
23 printf "%s" "$missing" > missing.dat
24
25 git add present.dat missing.dat
26 git commit -m "add objects"
27
28 delete_local_object "$missing_oid"
29
30 git config lfs.allowincompletepush true
31
32 git push origin main 2>&1 | tee push.log
33 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
34 echo >&2 "fatal: expected 'git push origin main' to succeed ..."
35 exit 1
36 fi
37
38 grep "LFS upload missing objects" push.log
39 grep " (missing) missing.dat ($missing_oid)" push.log
40
41 assert_server_object "$reponame" "$present_oid"
42 refute_server_object "$reponame" "$missing_oid"
43 )
44 end_test
45
46 begin_test "push allow missing object (lfs.allowincompletepush true) (git-lfs-transfer)"
47 (
48 set -e
49
50 setup_pure_ssh
51
52 reponame="push-ssh-allow-missing-object"
53 setup_remote_repo "$reponame"
54 clone_repo "$reponame" "$reponame"
55
56 sshurl=$(ssh_remote "$reponame")
57 git config lfs.url "$sshurl"
58
59 git lfs track "*.dat"
60 git add .gitattributes
61 git commit -m "initial commit"
62
63 present="present"
64 present_oid="$(calc_oid "$present")"
65 printf "%s" "$present" > present.dat
66
67 missing="missing"
68 missing_oid="$(calc_oid "$missing")"
69 printf "%s" "$missing" > missing.dat
70
71 git add present.dat missing.dat
72 git commit -m "add objects"
73
74 delete_local_object "$missing_oid"
75
76 git config lfs.allowincompletepush true
77
78 GIT_TRACE=1 git push origin main 2>&1 | tee push.log
79 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
80 echo >&2 "fatal: expected 'git push origin main' to succeed ..."
81 exit 1
82 fi
83
84 grep "pure SSH connection successful" push.log
85
86 grep "LFS upload missing objects" push.log
87 grep " (missing) missing.dat ($missing_oid)" push.log
88
89 assert_remote_object "$reponame" "$present_oid" "${#present}"
90 refute_remote_object "$reponame" "$missing_oid"
91 )
92 end_test
93
94 begin_test "push reject missing object (lfs.allowincompletepush false)"
95 (
96 set -e
97
98 reponame="push-reject-missing-object"
99 setup_remote_repo "$reponame"
100 clone_repo "$reponame" "$reponame"
101
102 git lfs track "*.dat"
103 git add .gitattributes
104 git commit -m "initial commit"
105
106 present="present"
107 present_oid="$(calc_oid "$present")"
108 printf "%s" "$present" > present.dat
109
110 missing="missing"
111 missing_oid="$(calc_oid "$missing")"
112 printf "%s" "$missing" > missing.dat
113
114 git add present.dat missing.dat
115 git commit -m "add objects"
116
117 delete_local_object "$missing_oid"
118
119 git config lfs.allowincompletepush false
120
121 GIT_TRACE=1 git push origin main 2>&1 | tee push.log
122 if [ "1" -ne "${PIPESTATUS[0]}" ]; then
123 echo >&2 "fatal: expected 'git push origin main' to fail ..."
124 exit 1
125 fi
126
127 grep "tq: stopping batched queue, object \"$missing_oid\" missing locally and on remote" push.log
128 grep "LFS upload failed:" push.log
129 grep " (missing) missing.dat ($missing_oid)" push.log
130
131 refute_server_object "$reponame" "$present_oid"
132 refute_server_object "$reponame" "$missing_oid"
133 )
134 end_test
135
136 begin_test "push reject missing object (lfs.allowincompletepush false) (git-lfs-transfer)"
137 (
138 set -e
139
140 setup_pure_ssh
141
142 reponame="push-ssh-reject-missing-object"
143 setup_remote_repo "$reponame"
144 clone_repo "$reponame" "$reponame"
145
146 sshurl=$(ssh_remote "$reponame")
147 git config lfs.url "$sshurl"
148
149 git lfs track "*.dat"
150 git add .gitattributes
151 git commit -m "initial commit"
152
153 present="present"
154 present_oid="$(calc_oid "$present")"
155 printf "%s" "$present" > present.dat
156
157 missing="missing"
158 missing_oid="$(calc_oid "$missing")"
159 printf "%s" "$missing" > missing.dat
160
161 git add present.dat missing.dat
162 git commit -m "add objects"
163
164 delete_local_object "$missing_oid"
165
166 git config lfs.allowincompletepush false
167
168 GIT_TRACE=1 git push origin main 2>&1 | tee push.log
169 if [ "1" -ne "${PIPESTATUS[0]}" ]; then
170 echo >&2 "fatal: expected 'git push origin main' to fail ..."
171 exit 1
172 fi
173
174 grep "pure SSH connection successful" push.log
175
176 grep "tq: stopping batched queue, object \"$missing_oid\" missing locally and on remote" push.log
177 grep "LFS upload failed:" push.log
178 grep " (missing) missing.dat ($missing_oid)" push.log
179
180 refute_remote_object "$reponame" "$present_oid"
181 refute_remote_object "$reponame" "$missing_oid"
182 )
183 end_test
184
185 begin_test "push reject missing object (lfs.allowincompletepush default)"
186 (
187 set -e
188
189 reponame="push-reject-missing-object-default"
190 setup_remote_repo "$reponame"
191 clone_repo "$reponame" "$reponame"
192
193 git lfs track "*.dat"
194 git add .gitattributes
195 git commit -m "initial commit"
196
197 present="present"
198 present_oid="$(calc_oid "$present")"
199 printf "%s" "$present" > present.dat
200
201 missing="missing"
202 missing_oid="$(calc_oid "$missing")"
203 printf "%s" "$missing" > missing.dat
204
205 git add present.dat missing.dat
206 git commit -m "add objects"
207
208 delete_local_object "$missing_oid"
209
210 GIT_TRACE=1 git push origin main 2>&1 | tee push.log
211 if [ "1" -ne "${PIPESTATUS[0]}" ]; then
212 echo >&2 "fatal: expected 'git push origin main' to fail ..."
213 exit 1
214 fi
215
216 grep "tq: stopping batched queue, object \"$missing_oid\" missing locally and on remote" push.log
217 grep "LFS upload failed:" push.log
218 grep " (missing) missing.dat ($missing_oid)" push.log
219
220 refute_server_object "$reponame" "$present_oid"
221 refute_server_object "$reponame" "$missing_oid"
222 )
223 end_test
224
225 begin_test "push reject missing object (lfs.allowincompletepush default) (git-lfs-transfer)"
226 (
227 set -e
228
229 setup_pure_ssh
230
231 reponame="push-ssh-reject-missing-object-default"
232 setup_remote_repo "$reponame"
233 clone_repo "$reponame" "$reponame"
234
235 sshurl=$(ssh_remote "$reponame")
236 git config lfs.url "$sshurl"
237
238 git lfs track "*.dat"
239 git add .gitattributes
240 git commit -m "initial commit"
241
242 present="present"
243 present_oid="$(calc_oid "$present")"
244 printf "%s" "$present" > present.dat
245
246 missing="missing"
247 missing_oid="$(calc_oid "$missing")"
248 printf "%s" "$missing" > missing.dat
249
250 git add present.dat missing.dat
251 git commit -m "add objects"
252
253 delete_local_object "$missing_oid"
254
255 GIT_TRACE=1 git push origin main 2>&1 | tee push.log
256 if [ "1" -ne "${PIPESTATUS[0]}" ]; then
257 echo >&2 "fatal: expected 'git push origin main' to fail ..."
258 exit 1
259 fi
260
261 grep "pure SSH connection successful" push.log
262
263 grep "tq: stopping batched queue, object \"$missing_oid\" missing locally and on remote" push.log
264 grep "LFS upload failed:" push.log
265 grep " (missing) missing.dat ($missing_oid)" push.log
266
267 refute_remote_object "$reponame" "$present_oid"
268 refute_remote_object "$reponame" "$missing_oid"
269 )
270 end_test
271
272 begin_test "push reject corrupt object (lfs.allowincompletepush default)"
273 (
274 set -e
275
276 reponame="push-reject-corrupt-object"
277 setup_remote_repo "$reponame"
278 clone_repo "$reponame" "$reponame"
279
280 git lfs track "*.dat"
281 git add .gitattributes
282 git commit -m "initial commit"
283
284 present="present"
285 present_oid="$(calc_oid "$present")"
286 printf "%s" "$present" > present.dat
287
288 corrupt="corrupt"
289 corrupt_oid="$(calc_oid "$corrupt")"
290 printf "%s" "$corrupt" > corrupt.dat
291
292 git add present.dat corrupt.dat
293 git commit -m "add objects"
294
295 corrupt_local_object "$corrupt_oid"
296
297 git push origin main 2>&1 | tee push.log
298 if [ "1" -ne "${PIPESTATUS[0]}" ]; then
299 echo >&2 "fatal: expected 'git push origin main' to fail ..."
300 exit 1
301 fi
302
303 grep "LFS upload failed:" push.log
304 grep " (corrupt) corrupt.dat ($corrupt_oid)" push.log
305
306 assert_server_object "$reponame" "$present_oid"
307 refute_server_object "$reponame" "$corrupt_oid"
308 )
309 end_test
310
311 begin_test "push reject corrupt object (lfs.allowincompletepush default) (git-lfs-transfer)"
312 (
313 set -e
314
315 setup_pure_ssh
316
317 reponame="push-ssh-reject-corrupt-object-default"
318 setup_remote_repo "$reponame"
319 clone_repo "$reponame" "$reponame"
320
321 sshurl=$(ssh_remote "$reponame")
322 git config lfs.url "$sshurl"
323
324 git lfs track "*.dat"
325 git add .gitattributes
326 git commit -m "initial commit"
327
328 present="present"
329 present_oid="$(calc_oid "$present")"
330 printf "%s" "$present" > present.dat
331
332 corrupt="corrupt"
333 corrupt_oid="$(calc_oid "$corrupt")"
334 printf "%s" "$corrupt" > corrupt.dat
335
336 git add present.dat corrupt.dat
337 git commit -m "add objects"
338
339 corrupt_local_object "$corrupt_oid"
340
341 GIT_TRACE=1 git push origin main 2>&1 | tee push.log
342 if [ "1" -ne "${PIPESTATUS[0]}" ]; then
343 echo >&2 "fatal: expected 'git push origin main' to fail ..."
344 exit 1
345 fi
346
347 grep "pure SSH connection successful" push.log
348
349 grep "LFS upload failed:" push.log
350 grep " (corrupt) corrupt.dat ($corrupt_oid)" push.log
351
352 assert_remote_object "$reponame" "$present_oid" "${#present}"
353 refute_remote_object "$reponame" "$corrupt_oid"
354 )
355 end_test