Debian Codegraph @

t/t-no-remote.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh"
4
5 reponame_src="$(basenamescip-shell system . . basename. "$0" ".sh")-src"
6 reponame_dst="$(basenamescip-shell system . . basename. "$0" ".sh")-dst"
7
8 begin_test "fetch lfs-tracked file despite no remote"
9 (
10 set -e
11
12 # First, a repo with an lfs-tracked file we can fetch from
13 setup_remote_repo_with_file "$reponame_src" "test_file.dat"
14
15 # Grab the rev for `git archive` later
16 echoscip-shell system . . echo. $(pwdscip-shell system . . pwd.)
17 rev=$(gitscip-shell system . . git. rev-parse HEAD)
18 cd ..
19
20 # Initialize a bare repo we can fetch into
21 mkdirscip-shell system . . mkdir. $reponame_dst
22 cd $reponame_dst
23 gitscip-shell system . . git. init . --bare
24 echoscip-shell system . . echo. $(pwdscip-shell system . . pwd.)
25 gitscip-shell system . . git. fetch "$GITSERVER/$reponame_src" refs/heads/main:refs/heads/main
26 gitscip-shell system . . git. archive $rev -o archive.out
27
28 # Verify archive contains our file
29 [scip-shell system . . `[`. 1 -eq "$(tarscip-shell system . . tar. -tvf archive.out test_file.dat | wcscip-shell system . . wc. -l)" ]
30 )
31 end_test
32
33 reponame_src_A="$(basenamescip-shell system . . basename. "$0" ".sh")-src-A"
34 reponame_src_B="$(basenamescip-shell system . . basename. "$0" ".sh")-src-B"
35 reponame_dst_2="$(basenamescip-shell system . . basename. "$0" ".sh")-dst-2"
36 begin_test "fallback ignored when remote present"
37 (
38 set -e
39
40 # Initialize 2 repos with different files
41 setup_remote_repo_with_file "$reponame_src_A" "test_file_A.dat"
42 rev=$(gitscip-shell system . . git. rev-parse HEAD)
43 cd ..
44 setup_remote_repo_with_file "$reponame_src_B" "test_file_B.dat"
45 cd ..
46
47 mkdirscip-shell system . . mkdir. $reponame_dst_2
48 cd $reponame_dst_2
49 gitscip-shell system . . git. init . --bare
50 echoscip-shell system . . echo. $(pwdscip-shell system . . pwd.)
51 # This part is subtle
52 # Add repo A as a remote and fetch from it
53 # But then fetch from repo B. This points FETCH_HEAD to repo B
54 # We're testing that git-lfs will ignore FETCH_HEAD, since FETCH_HEAD is
55 # a fallback, only used when no remote is set
56 gitscip-shell system . . git. remote add origin "$GITSERVER/$reponame_src_A"
57 gitscip-shell system . . git. fetch
58 gitscip-shell system . . git. fetch "$GITSERVER/$reponame_src_B" refs/heads/main:refs/heads/main
59 gitscip-shell system . . git. archive $rev -o archive.out
60
61 # Verify archive contains file from second repo, but not first repo
62 [scip-shell system . . `[`. 1 -eq "$(tarscip-shell system . . tar. -tvf archive.out test_file_A.dat | wcscip-shell system . . wc. -l)" ]
63 [scip-shell system . . `[`. 0 -eq "$(tarscip-shell system . . tar. -tvf archive.out test_file_B.dat | wcscip-shell system . . wc. -l)" ]
64 )
65 end_test
66