Debian Codegraph @

t/t-post-commit.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 begin_test "post-commit"
6 (
7 set -e
8
9 reponame="$(basenamescip-shell system . . basename. "$0" ".sh")"
10 setup_remote_repo "$reponame"
11
12 clone_repo "$reponame" "$reponame"
13
14 gitscip-shell system . . git. lfs track --lockable "*.dat"
15 gitscip-shell system . . git. lfs track "*.big" # not lockable
16 gitscip-shell system . . git. add .gitattributes
17 gitscip-shell system . . git. commit -m "add git attributes"
18
19 echoscip-shell system . . echo. "Come with me" > pcfile1.dat
20 echoscip-shell system . . echo. "and you'll be" > pcfile2.dat
21 echoscip-shell system . . echo. "in a world" > pcfile3.big
22 echoscip-shell system . . echo. "of pure imagination" > pcfile4.big
23
24 gitscip-shell system . . git. add *.dat
25 gitscip-shell system . . git. commit -m "Committed large files"
26
27 # New lockable files should have been made read-only now since not locked
28 refute_file_writeable pcfile1.dat
29 refute_file_writeable pcfile2.dat
30 assert_file_writeable pcfile3.big
31 assert_file_writeable pcfile4.big
32
33 gitscip-shell system . . git. push -u origin main
34
35 # now lock files, then edit
36 gitscip-shell system . . git. lfs lock pcfile1.dat
37 gitscip-shell system . . git. lfs lock pcfile2.dat
38
39 echoscip-shell system . . echo. "Take a look" > pcfile1.dat
40 echoscip-shell system . . echo. "and you'll see" > pcfile2.dat
41
42 gitscip-shell system . . git. add pcfile1.dat pcfile2.dat
43 gitscip-shell system . . git. commit -m "Updated"
44
45 # files should remain writeable since locked
46 assert_file_writeable pcfile1.dat
47 assert_file_writeable pcfile2.dat
48
49 )
50 end_test
51
52 begin_test "post-commit (locked file outside of LFS)"
53 (
54 set -e
55
56 reponame="post-commit-external"
57 setup_remote_repo "$reponame"
58 clone_repo "$reponame" "$reponame"
59
60 gitscip-shell system . . git. lfs install
61
62 # This step is intentionally done in two commits, due to a known bug bug in
63 # the post-checkout process LFS performs. It compares changed files from HEAD,
64 # which is an invalid previous state for the initial commit of a repository.
65 echoscip-shell system . . echo. "*.dat lockable" > .gitattributes
66 gitscip-shell system . . git. add .gitattributes
67 gitscip-shell system . . git. commit -m "initial commit"
68
69 echoscip-shell system . . echo. "hello" > a.dat
70 gitscip-shell system . . git. add a.dat
71 assert_file_writeable a.dat
72 gitscip-shell system . . git. commit -m "add a.dat"
73
74 refute_file_writeable a.dat
75 )
76 end_test
77
78 begin_test "post-commit does not enter submodules"
79 (
80 set -e
81
82 reponame="post-commit-submodules"
83 setup_remote_repo "$reponame"
84
85 clone_repo "$reponame" "$reponame"
86
87 gitscip-shell system . . git. lfs track --lockable "*.dat"
88 gitscip-shell system . . git. lfs track "*.big" # not lockable
89 gitscip-shell system . . git. add .gitattributes
90 gitscip-shell system . . git. commit -m "add git attributes"
91
92 mkdirscip-shell system . . mkdir. submodule
93 (cd submodule && gitscip-shell system . . git. init && echoscip-shell system . . echo. abc >foo && gitscip-shell system . . git. add foo && gitscip-shell system . . git. commit -m 'foo')
94 gitscip-shell system . . git. submodule add ./submodule submodule
95 gitscip-shell system . . git. commit -m 'Add submodule'
96
97 echoscip-shell system . . echo. "Come with me" > pcfile1.dat
98 echoscip-shell system . . echo. "and you'll be" > pcfile2.dat
99 echoscip-shell system . . echo. "in a world" > pcfile3.big
100 echoscip-shell system . . echo. "of pure imagination" > pcfile4.big
101
102 gitscip-shell system . . git. add *.dat
103 GIT_TRACE=1 gitscip-shell system . . git. commit -m "Committed large files" 2>&1 | teescip-shell system . . tee. output
104 grepscip-shell system . . grep. -E 'filepathfilter:.*submodule/foo' output && exit 1
105 truescip-shell system . . true.
106 )
107 end_test