-
Notifications
You must be signed in to change notification settings - Fork 0
/
vendoff.sh
executable file
·49 lines (46 loc) · 1.03 KB
/
vendoff.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
set -euo pipefail
PFX=":vendoff:"
command=${1:-}
echo "$PFX command=[$command]"
case "$command" in
on)
if [[ -d _novendor ]]; then
if [[ -d vendor ]]; then
echo "$PFX cannot move _novendor folder - something's in the way"
else
echo "$PFX move vendor to _novendor"
mv _novendor vendor
fi
fi
if [[ -d vendor ]]; then
echo "$PFX remove skip-worktree option"
pushd vendor
git update-index --no-skip-worktree $(git ls-files | tr '\n' ' ')
popd
fi
;;
off)
if [[ -d vendor ]]; then
echo "$PFX set skip-worktree option on vendor folder"
pushd vendor
git update-index --skip-worktree $(git ls-files | tr '\n' ' ')
popd
if [[ -d _novendor ]]; then
echo "$PFX cannot move vendor folder - something's in the way"
else
echo "$PFX move vendor to _novendor"
mv vendor _novendor
fi
else
echo "$PFX no vendor folder"
fi
;;
init)
echo "$PFX append _novendor to .gitignore"
echo "_novendor" >> .gitignore
;;
*)
echo "$PFX usage: $0 on|off|init"
exit 1
esac