Debian Codegraph @

t/fixtures/migrate.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 # assert_ref_unmoved ensures that the previous and current SHA1 of a given ref
4 # is equal by string comparison:
5 #
6 # assert_ref_unmoved "HEAD" "$previous_sha" "$current_sha"
7 #
8 # If the two are unequal (the ref has moved), a message is printed to stderr and
9 # the program exits.
10 assert_ref_unmovedscip-shell shell shell-project 0.0.0 assert_ref_unmoved().() {
11 local name="$1"
12 local prev_sha="$2"
13 local current_sha="$3"
14
15 if [scip-shell system . . `[`. "$prev_sha" != "$current_sha" ]; then
16 echoscip-shell system . . echo. >&2 "$name should not have moved (from: $prev_sha, to: $current_sha)"
17 exit 1
18 fi
19 }
20
21 # setup_local_branch_with_gitattrs creates a repository as follows:
22 #
23 # A---B
24 # \
25 # refs/heads/main
26 #
27 # - Commit 'A' has 120, in a.txt, and a corresponding entry in .gitattributes.
28 #
29 # If "0755" is passed as an argument, the .gitattributes file is created
30 # with that permissions mode.
31 # If "link" is passed as an argument, the .gitattributes file is created
32 # as a symlink to a gitattrs file.
33 setup_local_branch_with_gitattrsscip-shell shell shell-project 0.0.0 setup_local_branch_with_gitattrs().() {
34 set -e
35
36 reponame="migrate-single-local-branch-with-attrs"
37
38 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
39
40 lfstest-genrandom --base64 120 >a.txt
41
42 gitscip-shell system . . git. add a.txt
43 gitscip-shell system . . git. commit -m "initial commit"
44
45 gitscip-shell system . . git. lfs track "*.txt"
46 gitscip-shell system . . git. lfs track "*.other"
47
48 if [[ $1 == "0755" ]]; then
49 chmodscip-shell system . . chmod. +x .gitattributes
50 elif [[ $1 == "link" ]]; then
51 mvscip-shell system . . mv. .gitattributes gitattrs
52
53 add_symlink gitattrs .gitattributes
54
55 gitscip-shell system . . git. add gitattrs
56 fi
57
58 gitscip-shell system . . git. add .gitattributes
59 gitscip-shell system . . git. commit -m "add .gitattributes"
60 }
61
62 # setup_local_branch_with_nested_gitattrs creates a repository as follows:
63 #
64 # A---B
65 # \
66 # refs/heads/main
67 #
68 # - Commit 'A' has 120, in a.txt, and a corresponding entry in .gitattributes. There is also
69 # 140 in a.md, with no corresponding entry in .gitattributes.
70 # It also has 140 in subtree/a.md, and a corresponding entry in subtree/.gitattributes
71 setup_local_branch_with_nested_gitattrsscip-shell shell shell-project 0.0.0 setup_local_branch_with_nested_gitattrs().() {
72 set -e
73
74 reponame="migrate-single-local-branch-nested-attrs"
75
76 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
77
78 mkdirscip-shell system . . mkdir. b
79
80 lfstest-genrandom --base64 120 >a.txt
81 lfstest-genrandom --base64 140 >a.md
82 lfstest-genrandom --base64 140 >b/a.md
83
84 gitscip-shell system . . git. add a.txt a.md b/a.md
85 gitscip-shell system . . git. commit -m "initial commit"
86
87 gitscip-shell system . . git. lfs track "*.txt"
88
89 gitscip-shell system . . git. add .gitattributes
90 gitscip-shell system . . git. commit -m "add .gitattributes"
91
92 cd b
93
94 gitscip-shell system . . git. lfs track "*.md"
95
96 cd ..
97
98 gitscip-shell system . . git. add b/.gitattributes
99 gitscip-shell system . . git. commit -m "add nested .gitattributes"
100 }
101
102 # setup_single_local_branch_untracked creates a repository as follows:
103 #
104 # A---B
105 # \
106 # refs/heads/main
107 #
108 # - Commit 'A' has 120, in a.txt and 140 in a.md, with neither files tracked as
109 # pointers in Git LFS
110 setup_single_local_branch_untrackedscip-shell shell shell-project 0.0.0 setup_single_local_branch_untracked().() {
111 set -e
112
113 local name="${1:-a.md}"
114
115 reponame="migrate-single-local-branch-untracked"
116
117 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
118
119 gitscip-shell system . . git. commit --allow-empty -m "initial commit"
120
121 lfstest-genrandom --base64 120 >a.txt
122 lfstest-genrandom --base64 140 >"$name"
123
124 gitscip-shell system . . git. add a.txt "$name"
125 gitscip-shell system . . git. commit -m "add a.txt and $name"
126 }
127
128 # setup_single_local_branch_tracked creates a repository as follows:
129 #
130 # A---B
131 # \
132 # refs/heads/main
133 #
134 # - Commit 'A' has 120, in a.txt and 140 in a.md, with both files tracked as
135 # pointers in Git LFS
136 #
137 # If "0755" is passed as an argument, the .gitattributes file is created
138 # with that permissions mode.
139 # If "link" is passed as an argument, the .gitattributes file is created
140 # as a symlink to a gitattrs file.
141 setup_single_local_branch_trackedscip-shell shell shell-project 0.0.0 setup_single_local_branch_tracked().() {
142 set -e
143
144 reponame="migrate-single-local-branch-tracked"
145
146 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
147
148 echoscip-shell system . . echo. "*.txt filter=lfs diff=lfs merge=lfs -text" > .gitattributes
149 echoscip-shell system . . echo. "*.md filter=lfs diff=lfs merge=lfs -text" >> .gitattributes
150
151 if [[ $1 == "0755" ]]; then
152 chmodscip-shell system . . chmod. +x .gitattributes
153 fi
154
155 gitscip-shell system . . git. add .gitattributes
156 gitscip-shell system . . git. commit -m "initial commit"
157
158 lfstest-genrandom --base64 120 >a.txt
159 lfstest-genrandom --base64 140 >a.md
160
161 gitscip-shell system . . git. add a.txt a.md
162 gitscip-shell system . . git. commit -m "add a.{txt,md}"
163
164 if [[ $1 == "link" ]]; then
165 gitscip-shell system . . git. mv .gitattributes gitattrs
166
167 add_symlink gitattrs .gitattributes
168
169 gitscip-shell system . . git. commit -m "link .gitattributes"
170 fi
171 }
172
173 # setup_single_local_branch_complex_tracked creates a repository as follows:
174 #
175 # A
176 # \
177 # refs/heads/main
178 #
179 # - Commit 'A' has 1 byte of text in a.txt and dir/b.txt. According to the
180 # .gitattributes files, a.txt should be tracked using Git LFS, but b.txt should
181 # not be.
182 setup_single_local_branch_complex_trackedscip-shell shell shell-project 0.0.0 setup_single_local_branch_complex_tracked().() {
183 set -e
184
185 reponame="migrate-single-local-branch-complex-tracked"
186
187 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
188
189 mkdirscip-shell system . . mkdir. -p dir
190 echoscip-shell system . . echo. "*.txt filter=lfs diff=lfs merge=lfs -text" > .gitattributes
191 echoscip-shell system . . echo. "*.txt !filter !diff !merge" > dir/.gitattributes
192
193 printfscip-shell system . . printf. "a" > a.txt
194 printfscip-shell system . . printf. "b" > dir/b.txt
195
196 gitscip-shell system . . git. lfs uninstall
197
198 gitscip-shell system . . git. add .gitattributes dir/.gitattributes a.txt dir/b.txt
199 gitscip-shell system . . git. commit -m "initial commit"
200
201 gitscip-shell system . . git. lfs install
202 }
203
204 # setup_single_local_branch_tracked_corrupt creates a repository as follows:
205 #
206 # A
207 # \
208 # refs/heads/main
209 #
210 # - Commit 'A' has 120 bytes of random data in a.txt, and tracks *.txt under Git
211 # LFS, but a.txt is not stored as an LFS object.
212 #
213 # If "lfsmacro" is passed as an argument, a macro attribute definition
214 # which sets the LFS filter attribute is added to the .gitattributes file,
215 # and then referenced by the test file pattern attribute.
216 # If "macro" is passed as an argument, a macro attribute definition is
217 # added to the .gitattributes file.
218 # If "link" is passed as an argument, the .gitattributes file is created
219 # as a symlink to a gitattrs file.
220 # If "special" is passed as an argument, user-level (i.e., global) and
221 # repository-specific attribute files are created, and corresponding files
222 # named "a.out", "a.bin", "a.bat", and "a.dat" are added to the commit.
223 setup_single_local_branch_tracked_corruptscip-shell shell shell-project 0.0.0 setup_single_local_branch_tracked_corrupt().() {
224 set -e
225
226 reponame="migrate-single-local-branch-with-attrs-corrupt"
227
228 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
229
230 gitscip-shell system . . git. lfs uninstall
231
232 lfstest-genrandom --base64 120 >a.txt
233
234 if [[ $1 == "lfsmacro" ]]; then
235 printfscip-shell system . . printf. '[attr]lfs filter=lfs diff=lfs merge=lfs -text\n*.txt lfs\n' \
236 >.gitattributes
237 else
238 echoscip-shell system . . echo. "*.txt filter=lfs diff=lfs merge=lfs -text" > .gitattributes
239
240 if [[ $1 == "macro" ]]; then
241 echoscip-shell system . . echo. "[attr]foo foo" >>.gitattributes
242 elif [[ $1 == "link" ]]; then
243 mvscip-shell system . . mv. .gitattributes gitattrs
244
245 add_symlink gitattrs .gitattributes
246 elif [[ $1 == "special" ]]; then
247 echoscip-shell system . . echo. "*.dat filter=lfs" > .git/info/attributes
248 echoscip-shell system . . echo. "*.bin filter=lfs diff=lfs merge=lfs -text" >> .git/info/attributes
249 echoscip-shell system . . echo. "*.dat filter=overridden diff=lfs merge=lfs -text" >> .gitattributes
250 mkdirscip-shell system . . mkdir. -p "$HOME/.config/git"
251 echoscip-shell system . . echo. "*.bat filter=overridden diff=lfs merge=lfs -text" > "$HOME/.config/git/attributes"
252 echoscip-shell system . . echo. "*.out filter=lfs" >> "$HOME/.config/git/attributes"
253 echoscip-shell system . . echo. "*.bat filter=lfs" >> .gitattributes
254 echoscip-shell system . . echo. "*.out diff=lfs merge=lfs -text" >> .gitattributes
255
256 lfstest-genrandom --base64 120 > a.dat
257
258 lfstest-genrandom --base64 120 > a.bat
259
260 lfstest-genrandom --base64 120 > a.out
261
262 lfstest-genrandom --base64 120 > a.bin
263
264 gitscip-shell system . . git. add a.dat a.bat a.out a.bin
265 fi
266 fi
267
268 gitscip-shell system . . git. add .gitattributes a.txt
269 gitscip-shell system . . git. commit -m "initial commit"
270
271 gitscip-shell system . . git. lfs install
272 }
273
274 # setup_multiple_local_branches creates a repository as follows:
275 #
276 # B
277 # / \
278 # A refs/heads/my-feature
279 # \
280 # refs/heads/main
281 #
282 # - Commit 'A' has 120, 140 bytes of data in a.txt, and a.md, respectively.
283 #
284 # - Commit 'B' has 30 bytes of data in a.md, and includes commit 'A' as a
285 # parent.
286 setup_multiple_local_branchesscip-shell shell shell-project 0.0.0 setup_multiple_local_branches().() {
287 set -e
288
289 reponame="migrate-info-multiple-local-branches"
290
291 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
292
293 lfstest-genrandom --base64 120 >a.txt
294 lfstest-genrandom --base64 140 >a.md
295
296 gitscip-shell system . . git. add a.txt a.md
297 gitscip-shell system . . git. commit -m "initial commit"
298
299 gitscip-shell system . . git. checkout -b my-feature
300
301 lfstest-genrandom --base64 30 >a.md
302
303 gitscip-shell system . . git. add a.md
304 gitscip-shell system . . git. commit -m "add an additional 30 bytes to a.md"
305
306 gitscip-shell system . . git. checkout main
307 }
308
309 # setup_multiple_local_branches_with_alternate_names performs the same task
310 # as setup_multiple_local_branches, but creates a file with no extension.
311 setup_multiple_local_branches_with_alternate_namesscip-shell shell shell-project 0.0.0 setup_multiple_local_branches_with_alternate_names().() {
312 set -e
313
314 reponame="migrate-info-multiple-local-branches"
315
316 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
317
318 lfstest-genrandom --base64 120 >no_extension
319 lfstest-genrandom --base64 140 >a.txt
320
321 gitscip-shell system . . git. add no_extension a.txt
322 gitscip-shell system . . git. commit -m "initial commit"
323
324 gitscip-shell system . . git. checkout -b my-feature
325
326 lfstest-genrandom --base64 30 >a.txt
327 lfstest-genrandom --base64 100 >no_extension
328
329 gitscip-shell system . . git. add no_extension a.txt
330 gitscip-shell system . . git. commit -m "add an additional 30 bytes to a.txt"
331
332 gitscip-shell system . . git. checkout main
333 }
334
335 # setup_multiple_local_branches_with_gitattrs creates a repository in the same way
336 # as setup_multiple_local_branches, but also adds relevant lfs filters to the
337 # .gitattributes file in the main branch
338 setup_multiple_local_branches_with_gitattrsscip-shell shell shell-project 0.0.0 setup_multiple_local_branches_with_gitattrs().() {
339 set -e
340
341 setup_multiple_local_branchesscip-shell shell shell-project 0.0.0 setup_multiple_local_branches().
342
343 gitscip-shell system . . git. lfs track *.txt
344 gitscip-shell system . . git. lfs track *.md
345
346 gitscip-shell system . . git. add .gitattributes
347 gitscip-shell system . . git. commit -m "add .gitattributes"
348 }
349
350 # setup_multiple_local_branches_non_standard creates a repository as follows:
351 #
352 # refs/pull/1/head
353 # /
354 # |
355 # B
356 # / \
357 # A refs/heads/my-feature
358 # |\
359 # | refs/heads/main
360 # \
361 # refs/pull/1/base
362 #
363 # With the same contents in 'A' and 'B' as setup_multiple_local_branches.
364 setup_multiple_local_branches_non_standardscip-shell shell shell-project 0.0.0 setup_multiple_local_branches_non_standard().() {
365 set -e
366
367 setup_multiple_local_branchesscip-shell shell shell-project 0.0.0 setup_multiple_local_branches().
368
369 gitscip-shell system . . git. update-ref refs/pull/1/head "$(gitscip-shell system . . git. rev-parse my-feature)"
370 gitscip-shell system . . git. update-ref refs/pull/1/base "$(gitscip-shell system . . git. rev-parse main)"
371 }
372
373 # setup_multiple_local_branches_tracked creates a repo with exactly the same
374 # structure as in setup_multiple_local_branches, but with all files tracked by
375 # Git LFS
376 setup_multiple_local_branches_trackedscip-shell shell shell-project 0.0.0 setup_multiple_local_branches_tracked().() {
377 set -e
378
379 reponame="migrate-info-multiple-local-branches"
380
381 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
382
383 echoscip-shell system . . echo. "*.txt filter=lfs diff=lfs merge=lfs -text" > .gitattributes
384 echoscip-shell system . . echo. "*.md filter=lfs diff=lfs merge=lfs -text" >> .gitattributes
385 gitscip-shell system . . git. add .gitattributes
386 gitscip-shell system . . git. commit -m "initial commit"
387
388 lfstest-genrandom --base64 120 >a.txt
389 lfstest-genrandom --base64 140 >a.md
390
391 gitscip-shell system . . git. add a.txt a.md
392 gitscip-shell system . . git. commit -m "add a.{txt,md}"
393
394 gitscip-shell system . . git. checkout -b my-feature
395
396 lfstest-genrandom --base64 30 >a.md
397
398 gitscip-shell system . . git. add a.md
399 gitscip-shell system . . git. commit -m "add an additional 30 bytes to a.md"
400
401 gitscip-shell system . . git. checkout main
402 }
403
404 # setup_local_branch_with_space creates a repository as follows:
405 #
406 # A
407 # \
408 # refs/heads/main
409 #
410 # - Commit 'A' has 50 bytes in a file named "a file.txt".
411 setup_local_branch_with_spacescip-shell shell shell-project 0.0.0 setup_local_branch_with_space().() {
412 set -e
413
414 reponame="migrate-local-branch-with-space"
415 filename="a file.txt"
416
417 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
418
419 lfstest-genrandom --base64 50 >"$filename"
420
421 gitscip-shell system . . git. add "$filename"
422 gitscip-shell system . . git. commit -m "initial commit"
423 }
424
425 # setup_single_remote_branch creates a repository as follows:
426 #
427 # A---B
428 # \ \
429 # \ refs/heads/main
430 # \
431 # refs/remotes/origin/main
432 #
433 # - Commit 'A' has 120, 140 bytes of data in a.txt, and a.md, respectively. It
434 # is the latest commit pushed to the remote 'origin'.
435 #
436 # - Commit 'B' has 30, 50 bytes of data in a.txt, and a.md, respectively.
437 setup_single_remote_branchscip-shell shell shell-project 0.0.0 setup_single_remote_branch().() {
438 set -e
439
440 reponame="migrate-info-single-remote-branch"
441
442 remove_and_create_remote_reposcip-shell shell shell-project 0.0.0 remove_and_create_remote_repo(). "$reponame"
443
444 lfstest-genrandom --base64 120 >a.txt
445 lfstest-genrandom --base64 140 >a.md
446
447 gitscip-shell system . . git. add a.txt a.md
448 gitscip-shell system . . git. commit -m "initial commit"
449
450 gitscip-shell system . . git. push origin main
451
452 lfstest-genrandom --base64 30 >a.txt
453 lfstest-genrandom --base64 50 >a.md
454
455 gitscip-shell system . . git. add a.md a.txt
456 gitscip-shell system . . git. commit -m "add an additional 30, 50 bytes to a.{txt,md}"
457 }
458
459 setup_single_remote_branch_with_gitattrsscip-shell shell shell-project 0.0.0 setup_single_remote_branch_with_gitattrs().() {
460 set -e
461
462 setup_single_remote_branchscip-shell shell shell-project 0.0.0 setup_single_remote_branch().
463
464 gitscip-shell system . . git. lfs track *.txt
465 gitscip-shell system . . git. lfs track *.md
466
467 gitscip-shell system . . git. add .gitattributes
468 gitscip-shell system . . git. commit -m "add .gitattributes"
469 }
470
471 # Creates a repo identical to setup_single_remote_branch, except with *.md and
472 # *.txt files tracked by Git LFS
473 setup_single_remote_branch_trackedscip-shell shell shell-project 0.0.0 setup_single_remote_branch_tracked().() {
474 set -e
475
476 reponame="migrate-info-single-remote-branch"
477
478 remove_and_create_remote_reposcip-shell shell shell-project 0.0.0 remove_and_create_remote_repo(). "$reponame"
479
480 gitscip-shell system . . git. lfs track "*.md" "*.txt"
481 gitscip-shell system . . git. add .gitattributes
482 gitscip-shell system . . git. commit -m "initial commit"
483
484 lfstest-genrandom --base64 120 >a.txt
485 lfstest-genrandom --base64 140 >a.md
486
487 gitscip-shell system . . git. add a.txt a.md
488 gitscip-shell system . . git. commit -m "add a.{txt,md}"
489
490 gitscip-shell system . . git. push origin main
491
492 lfstest-genrandom --base64 30 >a.txt
493 lfstest-genrandom --base64 50 >a.md
494
495 gitscip-shell system . . git. add a.md a.txt
496 gitscip-shell system . . git. commit -m "add an additional 30, 50 bytes to a.{txt,md}"
497 }
498
499 # setup_multiple_remote_branches creates a repository as follows:
500 #
501 # C
502 # / \
503 # A---B refs/heads/my-feature
504 # \ \
505 # \ refs/heads/main
506 # \
507 # refs/remotes/origin/main
508 #
509 # - Commit 'A' has 10, 11 bytes of data in a.txt, and a.md, respectively. It is
510 # the latest commit pushed to the remote 'origin'.
511 #
512 # - Commit 'B' has 20, 21 bytes of data in a.txt, and a.md, respectively.
513 #
514 # - Commit 'C' has 30, 31 bytes of data in a.txt, and a.md, respectively. It is
515 # the latest commit on refs/heads/my-feature.
516 setup_multiple_remote_branchesscip-shell shell shell-project 0.0.0 setup_multiple_remote_branches().() {
517 set -e
518
519 reponame="migrate-info-exclude-remote-refs-given-branch"
520
521 remove_and_create_remote_reposcip-shell shell shell-project 0.0.0 remove_and_create_remote_repo(). "$reponame"
522
523 lfstest-genrandom --base64 10 >a.txt
524 lfstest-genrandom --base64 11 >a.md
525 gitscip-shell system . . git. add a.txt a.md
526 gitscip-shell system . . git. commit -m "add 10, 11 bytes, a.{txt,md}"
527
528 gitscip-shell system . . git. push origin main
529
530 lfstest-genrandom --base64 20 >a.txt
531 lfstest-genrandom --base64 21 >a.md
532 gitscip-shell system . . git. add a.txt a.md
533 gitscip-shell system . . git. commit -m "add 20, 21 bytes, a.{txt,md}"
534
535 gitscip-shell system . . git. checkout -b my-feature
536
537 lfstest-genrandom --base64 30 >a.txt
538 lfstest-genrandom --base64 31 >a.md
539 gitscip-shell system . . git. add a.txt a.md
540 gitscip-shell system . . git. commit -m "add 30, 31 bytes, a.{txt,md}"
541
542 gitscip-shell system . . git. checkout main
543 }
544
545 # Creates a repo identical to that in setup_multiple_remote_branches(), but
546 # with all files tracked by Git LFS
547 setup_multiple_remote_branches_gitattrsscip-shell shell shell-project 0.0.0 setup_multiple_remote_branches_gitattrs().() {
548 set -e
549
550 reponame="migrate-info-exclude-remote-refs-given-branch"
551
552 remove_and_create_remote_reposcip-shell shell shell-project 0.0.0 remove_and_create_remote_repo(). "$reponame"
553
554 gitscip-shell system . . git. lfs track "*.txt" "*.md"
555 gitscip-shell system . . git. add .gitattributes
556 gitscip-shell system . . git. commit -m "initial commit"
557
558 lfstest-genrandom --base64 10 >a.txt
559 lfstest-genrandom --base64 11 >a.md
560 gitscip-shell system . . git. add a.txt a.md
561 gitscip-shell system . . git. commit -m "add 10, 11 bytes, a.{txt,md}"
562
563 gitscip-shell system . . git. push origin main
564
565 lfstest-genrandom --base64 20 >a.txt
566 lfstest-genrandom --base64 21 >a.md
567 gitscip-shell system . . git. add a.txt a.md
568 gitscip-shell system . . git. commit -m "add 20, 21 bytes, a.{txt,md}"
569
570 gitscip-shell system . . git. checkout -b my-feature
571
572 lfstest-genrandom --base64 30 >a.txt
573 lfstest-genrandom --base64 31 >a.md
574 gitscip-shell system . . git. add a.txt a.md
575 gitscip-shell system . . git. commit -m "add 30, 31 bytes, a.{txt,md}"
576
577 gitscip-shell system . . git. checkout main
578 }
579
580 # setup_single_local_branch_with_tags creates a repository as follows:
581 #
582 # A---B
583 # |\
584 # | refs/heads/main
585 # |
586 # \
587 # refs/tags/v1.0.0
588 #
589 # - Commit 'A' has 1 byte of data in 'a.txt'
590 # - Commit 'B' has 2 bytes of data in 'a.txt', and is tagged at 'v1.0.0'.
591 setup_single_local_branch_with_tagsscip-shell shell shell-project 0.0.0 setup_single_local_branch_with_tags().() {
592 set -e
593
594 reponame="migrate-single-local-branch-tags"
595
596 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
597
598 lfstest-genrandom --base64 1 >a.txt
599
600 gitscip-shell system . . git. add a.txt
601 gitscip-shell system . . git. commit -m "initial commit"
602
603 lfstest-genrandom --base64 2 >a.txt
604
605 gitscip-shell system . . git. add a.txt
606 gitscip-shell system . . git. commit -m "secondary commit"
607 gitscip-shell system . . git. tag "v1.0.0"
608 }
609
610 # setup_single_local_branch_with_annotated_tags creates a repository as follows:
611 #
612 # A---B
613 # |\
614 # | refs/heads/main
615 # |
616 # \
617 # refs/tags/v1.0.0 (annotated)
618 #
619 # - Commit 'A' has 1 byte of data in 'a.txt'
620 # - Commit 'B' has 2 bytes of data in 'a.txt', and is tagged (with annotation)
621 # at 'v1.0.0'.
622 setup_single_local_branch_with_annotated_tagsscip-shell shell shell-project 0.0.0 setup_single_local_branch_with_annotated_tags().() {
623 set -e
624
625 reponame="migrate-single-local-branch-annotated-tags"
626
627 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
628
629 lfstest-genrandom --base64 1 >a.txt
630
631 gitscip-shell system . . git. add a.txt
632 gitscip-shell system . . git. commit -m "initial commit"
633
634 lfstest-genrandom --base64 2 >a.txt
635
636 gitscip-shell system . . git. add a.txt
637 gitscip-shell system . . git. commit -m "secondary commit"
638 gitscip-shell system . . git. tag "v1.0.0" -m "v1.0.0"
639 }
640
641 setup_multiple_remotesscip-shell shell shell-project 0.0.0 setup_multiple_remotes().() {
642 set -e
643
644 reponame="migrate-multiple-remotes"
645 remove_and_create_remote_reposcip-shell shell shell-project 0.0.0 remove_and_create_remote_repo(). "$reponame"
646
647 forkname="$(gitscip-shell system . . git. remote -v \
648 | head -n1 \
649 | cut -d ' ' -f 1 \
650 | sed -e 's/^.*\///g')-fork"
651 ( setup_remote_repo "$forkname" )
652
653 gitscip-shell system . . git. remote add fork "$GITSERVER/$forkname"
654
655 lfstest-genrandom --base64 16 >a.txt
656 gitscip-shell system . . git. add a.txt
657 gitscip-shell system . . git. commit -m "initial commit"
658 gitscip-shell system . . git. push origin main
659
660 lfstest-genrandom --base64 16 >a.txt
661 gitscip-shell system . . git. add a.txt
662 gitscip-shell system . . git. commit -m "another commit"
663 gitscip-shell system . . git. push fork main
664 }
665
666 # setup_single_local_branch_deep_trees creates a repository as follows:
667 #
668 # A
669 # \
670 # refs/heads/main
671 #
672 # - Commit 'A' has 120 bytes of data in 'foo/bar/baz/a.txt'.
673 setup_single_local_branch_deep_treesscip-shell shell shell-project 0.0.0 setup_single_local_branch_deep_trees().() {
674 set -e
675
676 reponame="migrate-single-local-branch-with-deep-trees"
677 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
678
679 mkdirscip-shell system . . mkdir. -p foo/bar/baz
680 lfstest-genrandom --base64 120 >foo/bar/baz/a.txt
681
682 gitscip-shell system . . git. add foo/bar/baz/a.txt
683 gitscip-shell system . . git. commit -m "initial commit"
684 }
685
686 # setup_single_local_branch_same_file_tree_ext creates a repository as follows:
687 #
688 # A
689 # \
690 # refs/heads/main
691 #
692 # - Commit 'A' has 120 bytes of data in each of 'a.txt`, `foo/a.txt',
693 # `bar.txt/b.md`, and `bar.txt/b.txt`.
694 setup_single_local_branch_same_file_tree_extscip-shell shell shell-project 0.0.0 setup_single_local_branch_same_file_tree_ext().() {
695 set -e
696
697 reponame="migrate-single-local-branch-with-same-file-tree-ext"
698 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
699
700 mkdirscip-shell system . . mkdir. -p foo bar.txt
701 lfstest-genrandom --base64 120 >a.txt
702 lfstest-genrandom --base64 120 >foo/a.txt
703 lfstest-genrandom --base64 120 >bar.txt/b.md
704 lfstest-genrandom --base64 120 >bar.txt/b.txt
705
706 gitscip-shell system . . git. add a.txt foo bar.txt
707 gitscip-shell system . . git. commit -m "initial commit"
708 }
709
710 # setup_local_branch_with_symlink creates a repository as follows:
711 #
712 # A
713 # \
714 # refs/heads/main
715 #
716 # - Commit 'A' has 120, in a.txt, and a symbolic link link.txt to a.txt.
717 setup_local_branch_with_symlinkscip-shell shell shell-project 0.0.0 setup_local_branch_with_symlink().() {
718 set -e
719
720 reponame="migrate-single-local-branch-with-symlink"
721
722 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
723
724 lfstest-genrandom --base64 120 >a.txt
725
726 gitscip-shell system . . git. add a.txt
727 gitscip-shell system . . git. commit -m "initial commit"
728
729 add_symlink "a.txt" "link.txt"
730 gitscip-shell system . . git. commit -m "add symlink"
731 }
732
733 # setup_local_branch_with_dirty_copy creates a repository as follows:
734 #
735 # A
736 # \
737 # refs/heads/main
738 #
739 # - Commit 'A' has the contents "a.txt in a.txt, and marks a.txt as unclean
740 # in the working copy.
741 setup_local_branch_with_dirty_copyscip-shell shell shell-project 0.0.0 setup_local_branch_with_dirty_copy().() {
742 set -e
743
744 reponame="migrate-single-local-branch-with-dirty-copy"
745 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
746
747 printfscip-shell system . . printf. "a.txt" > a.txt
748
749 gitscip-shell system . . git. add a.txt
750 gitscip-shell system . . git. commit -m "initial commit"
751
752 printfscip-shell system . . printf. "2" >> a.txt
753 }
754
755 # setup_local_branch_with_copied_file creates a repository as follows:
756 #
757 # A
758 # \
759 # refs/heads/main
760 #
761 # - Commit 'A' has the contents "a.txt" in a.txt, and another identical file
762 # (same name and content) in another directory.
763 setup_local_branch_with_copied_filescip-shell shell shell-project 0.0.0 setup_local_branch_with_copied_file().() {
764 set -e
765
766 reponame="migrate-single-local-branch-with-copied-file"
767 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
768
769 printfscip-shell system . . printf. "a.txt" > a.txt
770 mkdirscip-shell system . . mkdir. dir
771 cpscip-shell system . . cp. a.txt dir/
772
773 gitscip-shell system . . git. add a.txt dir/a.txt
774 gitscip-shell system . . git. commit -m "initial commit"
775 }
776
777 # setup_local_branch_with_special_character_files creates a repository as follows:
778 #
779 # A
780 # \
781 # refs/heads/main
782 #
783 # - Commit 'A' has binary files with special characters
784 setup_local_branch_with_special_character_filesscip-shell shell shell-project 0.0.0 setup_local_branch_with_special_character_files().() {
785 set -e
786
787 reponame="migrate-single-local-branch-with-special-filenames"
788 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo(). "$reponame"
789
790 lfstest-genrandom 80 >'./test - special.bin'
791 lfstest-genrandom 100 >'./test (test2) special.bin'
792 # Windows does not allow creation of files with '*'
793 [scip-shell system . . `[`. "$IS_WINDOWS" -eq '1' ] || lfstest-genrandom 120 >'./test * ** special.bin'
794
795 gitscip-shell system . . git. add *.bin
796 gitscip-shell system . . git. commit -m "initial commit"
797 }
798
799 # make_bare converts the existing full checkout of a repository into a bare one,
800 # and then `cd`'s into it.
801 make_barescip-shell shell shell-project 0.0.0 make_bare().() {
802 reponame=$(basenamescip-shell system . . basename. "$(pwdscip-shell system . . pwd.)")
803 mvscip-shell system . . mv. .git "../$reponame.git"
804
805 cd ..
806
807 rmscip-shell system . . rm. -rf "$reponame"
808 cd "$reponame.git"
809
810 gitscip-shell system . . git. config --bool core.bare true
811 }
812
813 # remove_and_create_local_repo removes, creates, and checks out a local
814 # repository given by a particular name:
815 #
816 # remove_and_create_local_repo "$reponame"
817 remove_and_create_local_reposcip-shell shell shell-project 0.0.0 remove_and_create_local_repo().() {
818 local reponame="$1-$(lfstest-genrandom --base64url 32)"
819
820 gitscip-shell system . . git. init "$reponame"
821 cd "$reponame"
822 }
823
824 # remove_and_create_remote_repo removes, creates, and checks out a remote
825 # repository both locally and on the gitserver, given by a particular name:
826 #
827 # remove_and_create_remote_repo "$reponame"
828 remove_and_create_remote_reposcip-shell shell shell-project 0.0.0 remove_and_create_remote_repo().() {
829 local reponame="$1-$(lfstest-genrandom --base64url 32)"
830
831 setup_remote_repo "$reponame"
832 clone_repo "$reponame" "$reponame"
833
834 rmscip-shell system . . rm. clone.log
835 }