Debian Codegraph @

t/t-uninstall.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 "uninstall outside repository"
6 (
7 set -e
8
9 mkdirscip-shell system . . mkdir. uninstall-test
10 cd uninstall-test
11
12 smudge="$(gitscip-shell system . . git. config filter.lfs.smudge)"
13 clean="$(gitscip-shell system . . git. config filter.lfs.clean)"
14 filter="$(gitscip-shell system . . git. config filter.lfs.process)"
15
16 printfscip-shell system . . printf. "%s" "$smudge" | grepscip-shell system . . grep. "git-lfs smudge"
17 printfscip-shell system . . printf. "%s" "$clean" | grepscip-shell system . . grep. "git-lfs clean"
18 printfscip-shell system . . printf. "%s" "$filter" | grepscip-shell system . . grep. "git-lfs filter-process"
19
20 # uninstall multiple times to trigger https://github.com/git-lfs/git-lfs/issues/529
21 gitscip-shell system . . git. lfs uninstall
22
23 [scip-shell system . . `[`. ! -e "lfs" ]
24
25 for opt in "" "--skip-repo"
26 do
27 gitscip-shell system . . git. lfs install
28 gitscip-shell system . . git. lfs uninstall $opt | teescip-shell system . . tee. uninstall.log
29 grepscip-shell system . . grep. "Global Git LFS configuration has been removed." uninstall.log
30
31 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config --global filter.lfs.smudge)" ]
32 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config --global filter.lfs.clean)" ]
33 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config --global filter.lfs.process)" ]
34
35 catscip-shell system . . cat. $HOME/.gitconfig
36 [scip-shell system . . `[`. 0 -eq "$(grepscip-shell system . . grep. -c 'filter "lfs"' $HOME/.gitconfig)" ]
37 done
38 )
39 end_test
40
41 begin_test "uninstall outside repository without access to .git/lfs"
42 (
43 set -e
44
45 mkdirscip-shell system . . mkdir. uninstall-no-lfs
46 cd uninstall-no-lfs
47
48 mkdirscip-shell system . . mkdir. .git
49 touchscip-shell system . . touch. .git/lfs
50 touchscip-shell system . . touch. lfs
51
52 [scip-shell system . . `[`. "" != "$(gitscip-shell system . . git. config --global filter.lfs.smudge)" ]
53 [scip-shell system . . `[`. "" != "$(gitscip-shell system . . git. config --global filter.lfs.clean)" ]
54 [scip-shell system . . `[`. "" != "$(gitscip-shell system . . git. config --global filter.lfs.process)" ]
55
56 gitscip-shell system . . git. lfs uninstall
57
58 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config --global filter.lfs.smudge)" ]
59 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config --global filter.lfs.clean)" ]
60 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config --global filter.lfs.process)" ]
61 )
62
63 begin_test "uninstall inside repository with --skip-repo"
64 (
65 set -e
66
67 reponame="$(basenamescip-shell system . . basename. "$0" ".sh")-skip-repo"
68 mkdirscip-shell system . . mkdir. "$reponame"
69 cd "$reponame"
70 gitscip-shell system . . git. init
71 gitscip-shell system . . git. lfs install
72
73 [scip-shell system . . `[`. -f .git/hooks/pre-push ]
74 grepscip-shell system . . grep. "git-lfs" .git/hooks/pre-push
75
76 [scip-shell system . . `[`. "git-lfs smudge -- %f" = "$(gitscip-shell system . . git. config filter.lfs.smudge)" ]
77 [scip-shell system . . `[`. "git-lfs clean -- %f" = "$(gitscip-shell system . . git. config filter.lfs.clean)" ]
78 [scip-shell system . . `[`. "git-lfs filter-process" = "$(gitscip-shell system . . git. config filter.lfs.process)" ]
79
80 gitscip-shell system . . git. lfs uninstall --skip-repo
81
82 [scip-shell system . . `[`. -f .git/hooks/pre-push ]
83 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config filter.lfs.smudge)" ]
84 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config filter.lfs.clean)" ]
85 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config filter.lfs.process)" ]
86 )
87 end_test
88
89 begin_test "uninstall inside repository with default pre-push hook"
90 (
91 set -e
92
93 reponame="$(basenamescip-shell system . . basename. "$0" ".sh")-hook"
94 mkdirscip-shell system . . mkdir. "$reponame"
95 cd "$reponame"
96 gitscip-shell system . . git. init
97 gitscip-shell system . . git. lfs install
98
99 [scip-shell system . . `[`. -f .git/hooks/pre-push ]
100 grepscip-shell system . . grep. "git-lfs" .git/hooks/pre-push
101
102 [scip-shell system . . `[`. "git-lfs smudge -- %f" = "$(gitscip-shell system . . git. config filter.lfs.smudge)" ]
103 [scip-shell system . . `[`. "git-lfs clean -- %f" = "$(gitscip-shell system . . git. config filter.lfs.clean)" ]
104 [scip-shell system . . `[`. "git-lfs filter-process" = "$(gitscip-shell system . . git. config filter.lfs.process)" ]
105
106 gitscip-shell system . . git. lfs uninstall
107
108 [scip-shell system . . `[`. -f .git/hooks/pre-push ] && {
109 echoscip-shell system . . echo. "expected .git/hooks/pre-push to be deleted"
110 exit 1
111 }
112 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config filter.lfs.smudge)" ]
113 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config filter.lfs.clean)" ]
114 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config filter.lfs.process)" ]
115 )
116 end_test
117
118 begin_test "uninstall inside repository without lfs pre-push hook"
119 (
120 set -e
121
122 reponame="$(basenamescip-shell system . . basename. "$0" ".sh")-no-hook"
123 mkdirscip-shell system . . mkdir. "$reponame"
124 cd "$reponame"
125 gitscip-shell system . . git. init
126 gitscip-shell system . . git. lfs install
127 echoscip-shell system . . echo. "something something git-lfs" > .git/hooks/pre-push
128
129
130 [scip-shell system . . `[`. -f .git/hooks/pre-push ]
131 [scip-shell system . . `[`. "something something git-lfs" = "$(catscip-shell system . . cat. .git/hooks/pre-push)" ]
132
133 [scip-shell system . . `[`. "git-lfs smudge -- %f" = "$(gitscip-shell system . . git. config filter.lfs.smudge)" ]
134 [scip-shell system . . `[`. "git-lfs clean -- %f" = "$(gitscip-shell system . . git. config filter.lfs.clean)" ]
135 [scip-shell system . . `[`. "git-lfs filter-process" = "$(gitscip-shell system . . git. config filter.lfs.process)" ]
136
137 gitscip-shell system . . git. lfs uninstall
138
139 [scip-shell system . . `[`. -f .git/hooks/pre-push ]
140 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config filter.lfs.smudge)" ]
141 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config filter.lfs.clean)" ]
142 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config filter.lfs.process)" ]
143 )
144 end_test
145
146 begin_test "uninstall hooks inside repository"
147 (
148 set -e
149
150 reponame="$(basenamescip-shell system . . basename. "$0" ".sh")-only-hook"
151 mkdirscip-shell system . . mkdir. "$reponame"
152 cd "$reponame"
153 gitscip-shell system . . git. init
154 gitscip-shell system . . git. lfs install
155
156 [scip-shell system . . `[`. -f .git/hooks/pre-push ]
157 grepscip-shell system . . grep. "git-lfs" .git/hooks/pre-push
158
159 [scip-shell system . . `[`. "git-lfs smudge -- %f" = "$(gitscip-shell system . . git. config filter.lfs.smudge)" ]
160 [scip-shell system . . `[`. "git-lfs clean -- %f" = "$(gitscip-shell system . . git. config filter.lfs.clean)" ]
161 [scip-shell system . . `[`. "git-lfs filter-process" = "$(gitscip-shell system . . git. config filter.lfs.process)" ]
162
163 gitscip-shell system . . git. lfs uninstall hooks
164
165 [scip-shell system . . `[`. -f .git/hooks/pre-push ] && {
166 echoscip-shell system . . echo. "expected .git/hooks/pre-push to be deleted"
167 exit 1
168 }
169
170 [scip-shell system . . `[`. "git-lfs smudge -- %f" = "$(gitscip-shell system . . git. config filter.lfs.smudge)" ]
171 [scip-shell system . . `[`. "git-lfs clean -- %f" = "$(gitscip-shell system . . git. config filter.lfs.clean)" ]
172 [scip-shell system . . `[`. "git-lfs filter-process" = "$(gitscip-shell system . . git. config filter.lfs.process)" ]
173 )
174 end_test
175
176 begin_test "uninstall --local outside repository"
177 (
178 set -e
179
180 # If run inside the git-lfs source dir this will update its .git/config & cause issues
181 if [scip-shell system . . `[`. "$GIT_LFS_TEST_DIR" == "" ]; then
182 echoscip-shell system . . echo. "Skipping uninstall --local because GIT_LFS_TEST_DIR is not set"
183 exit 0
184 fi
185
186 has_test_dir || exit 0
187
188 set +e
189 gitscip-shell system . . git. lfs uninstall --local >out.log
190 res=$?
191 set -e
192
193 [scip-shell system . . `[`. "Not in a Git repository." = "$(catscip-shell system . . cat. out.log)" ]
194 [scip-shell system . . `[`. "0" != "$res" ]
195 )
196 end_test
197
198 begin_test "uninstall --local with conflicting scope"
199 (
200 set -e
201
202 reponame="$(basenamescip-shell system . . basename. "$0" ".sh")-scope-conflict"
203 mkdirscip-shell system . . mkdir. "$reponame"
204 cd "$reponame"
205 gitscip-shell system . . git. init
206
207 set +e
208 gitscip-shell system . . git. lfs uninstall --local --system 2>err.log
209 res=$?
210 set -e
211
212 [scip-shell system . . `[`. "Only one of the --local, --system, --worktree, and --file options can be specified." = "$(catscip-shell system . . cat. err.log)" ]
213 [scip-shell system . . `[`. "0" != "$res" ]
214 )
215 end_test
216
217 begin_test "uninstall --local"
218 (
219 set -e
220
221 # old values that should be ignored by `uninstall --local`
222 gitscip-shell system . . git. config --global filter.lfs.smudge "global smudge"
223 gitscip-shell system . . git. config --global filter.lfs.clean "global clean"
224 gitscip-shell system . . git. config --global filter.lfs.process "global filter"
225
226 reponame="$(basenamescip-shell system . . basename. "$0" ".sh")-local"
227 mkdirscip-shell system . . mkdir. "$reponame"
228 cd "$reponame"
229 gitscip-shell system . . git. init
230 gitscip-shell system . . git. lfs install --local
231
232 # local configs are correct
233 [scip-shell system . . `[`. "git-lfs smudge -- %f" = "$(gitscip-shell system . . git. config filter.lfs.smudge)" ]
234 [scip-shell system . . `[`. "git-lfs smudge -- %f" = "$(gitscip-shell system . . git. config --local filter.lfs.smudge)" ]
235 [scip-shell system . . `[`. "git-lfs clean -- %f" = "$(gitscip-shell system . . git. config filter.lfs.clean)" ]
236 [scip-shell system . . `[`. "git-lfs clean -- %f" = "$(gitscip-shell system . . git. config --local filter.lfs.clean)" ]
237 [scip-shell system . . `[`. "git-lfs filter-process" = "$(gitscip-shell system . . git. config filter.lfs.process)" ]
238 [scip-shell system . . `[`. "git-lfs filter-process" = "$(gitscip-shell system . . git. config --local filter.lfs.process)" ]
239
240 # global configs
241 [scip-shell system . . `[`. "global smudge" = "$(gitscip-shell system . . git. config --global filter.lfs.smudge)" ]
242 [scip-shell system . . `[`. "global clean" = "$(gitscip-shell system . . git. config --global filter.lfs.clean)" ]
243 [scip-shell system . . `[`. "global filter" = "$(gitscip-shell system . . git. config --global filter.lfs.process)" ]
244
245 gitscip-shell system . . git. lfs uninstall --local 2>&1 | teescip-shell system . . tee. uninstall.log
246 if [scip-shell system . . `[`. ${PIPESTATUS[0]} -ne 0 ]; then
247 echoscip-shell system . . echo. >&2 "fatal: expected 'git lfs uninstall --local' to succeed"
248 exit 1
249 fi
250 [scip-shell system . . `[`. 0 -eq "$(grepscip-shell system . . grep. -c "Global Git LFS configuration has been removed." uninstall.log)" ]
251
252 # global configs
253 [scip-shell system . . `[`. "global smudge" = "$(gitscip-shell system . . git. config filter.lfs.smudge)" ]
254 [scip-shell system . . `[`. "global smudge" = "$(gitscip-shell system . . git. config --global filter.lfs.smudge)" ]
255 [scip-shell system . . `[`. "global clean" = "$(gitscip-shell system . . git. config filter.lfs.clean)" ]
256 [scip-shell system . . `[`. "global clean" = "$(gitscip-shell system . . git. config --global filter.lfs.clean)" ]
257 [scip-shell system . . `[`. "global filter" = "$(gitscip-shell system . . git. config filter.lfs.process)" ]
258 [scip-shell system . . `[`. "global filter" = "$(gitscip-shell system . . git. config --global filter.lfs.process)" ]
259
260 # local configs are empty
261 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config --local filter.lfs.smudge)" ]
262 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config --local filter.lfs.clean)" ]
263 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config --local filter.lfs.process)" ]
264 )
265 end_test
266
267 begin_test "uninstall --file"
268 (
269 set -e
270
271 # old values that should be ignored by `uninstall --local`
272 gitscip-shell system . . git. config --global filter.lfs.smudge "global smudge"
273 gitscip-shell system . . git. config --global filter.lfs.clean "global clean"
274 gitscip-shell system . . git. config --global filter.lfs.process "global filter"
275
276 reponame="$(basenamescip-shell system . . basename. "$0" ".sh")-file"
277 mkdirscip-shell system . . mkdir. "$reponame"
278 cd "$reponame"
279 gitscip-shell system . . git. init
280 gitscip-shell system . . git. lfs install --file=test-file
281
282 # local configs are correct
283 [scip-shell system . . `[`. "git-lfs smudge -- %f" = "$(gitscip-shell system . . git. config --file test-file filter.lfs.smudge)" ]
284 [scip-shell system . . `[`. "git-lfs clean -- %f" = "$(gitscip-shell system . . git. config --file test-file filter.lfs.clean)" ]
285 [scip-shell system . . `[`. "git-lfs filter-process" = "$(gitscip-shell system . . git. config --file test-file filter.lfs.process)" ]
286
287 # global configs
288 [scip-shell system . . `[`. "global smudge" = "$(gitscip-shell system . . git. config --global filter.lfs.smudge)" ]
289 [scip-shell system . . `[`. "global clean" = "$(gitscip-shell system . . git. config --global filter.lfs.clean)" ]
290 [scip-shell system . . `[`. "global filter" = "$(gitscip-shell system . . git. config --global filter.lfs.process)" ]
291
292 gitscip-shell system . . git. lfs uninstall --file=test-file 2>&1 | teescip-shell system . . tee. uninstall.log
293 if [scip-shell system . . `[`. ${PIPESTATUS[0]} -ne 0 ]; then
294 echoscip-shell system . . echo. >&2 "fatal: expected 'git lfs uninstall --file=test-file' to succeed"
295 exit 1
296 fi
297 # At present, we expect this message to always be output because the --file
298 # option was intended for use with alternative global configuration files
299 # like $XDG_CONFIG_HOME/git/config, although users may in practice use the
300 # the --file option on arbitrary files.
301 grepscip-shell system . . grep. "Global Git LFS configuration has been removed." uninstall.log
302
303 # global configs
304 [scip-shell system . . `[`. "global smudge" = "$(gitscip-shell system . . git. config filter.lfs.smudge)" ]
305 [scip-shell system . . `[`. "global smudge" = "$(gitscip-shell system . . git. config --global filter.lfs.smudge)" ]
306 [scip-shell system . . `[`. "global clean" = "$(gitscip-shell system . . git. config filter.lfs.clean)" ]
307 [scip-shell system . . `[`. "global clean" = "$(gitscip-shell system . . git. config --global filter.lfs.clean)" ]
308 [scip-shell system . . `[`. "global filter" = "$(gitscip-shell system . . git. config filter.lfs.process)" ]
309 [scip-shell system . . `[`. "global filter" = "$(gitscip-shell system . . git. config --global filter.lfs.process)" ]
310
311 # local configs are empty
312 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config --file test-file filter.lfs.smudge)" ]
313 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config --file test-file filter.lfs.clean)" ]
314 [scip-shell system . . `[`. "" = "$(gitscip-shell system . . git. config --file test-file filter.lfs.process)" ]
315 )
316 end_test