Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit 404ac48

Browse files
Merge pull request #104 from pmorie/vendor
Add contrib/vendor -c to clean deps
2 parents cc69905 + 9cb0ec7 commit 404ac48

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

contrib/vendor

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
#!/bin/bash -eu
22

33
function usage() {
4-
echo "vendor -l|-v <Package URL>"
5-
echo "-l List packages that may need to be vendored"
4+
echo "vendor -l|-v <Package URL>|-u <Package URL>|-c"
5+
echo "-l list packages that may need to be vendored"
66
echo "-v vendor a package"
77
echo "-u update a vendored package"
8+
echo "-c clean vendored dependencies"
89
exit 1
910
}
1011

1112
list=false
1213
vendor=false
1314
update=false
15+
clean=false
16+
count=0
1417

15-
while getopts "lvu" o; do
18+
while getopts "lvuc" o; do
1619
case "${o}" in
17-
l) list=true;;
18-
v) vendor=true;;
19-
u) update=true;;
20+
l) list=true; count=$((count+1));;
21+
v) vendor=true; count=$((count+1));;
22+
u) update=true; count=$((count+1));;
23+
c) clean=true; count=$((count+1));;
2024
*) usage;;
2125
esac
2226
done
2327

24-
if $list && [ "$vendor" -o "$update" ]; then
25-
usage
26-
exit
27-
fi
28-
29-
if ! $list && ! $vendor && ! $update; then
28+
if [ "$count" -ne "1" ]; then
3029
usage
3130
exit
3231
fi
@@ -69,9 +68,12 @@ if $list; then
6968
popd > /dev/null
7069

7170
rm -rf /tmp/vendor_pkg_list
72-
fi
73-
74-
if [[ $vendor || $update ]]; then
71+
elif $clean; then
72+
echo "Cleaning vendored dependencies"
73+
for dot_a in `find vendor/ -name *.a | cut -c 8-`; do
74+
rm -f vendor/$dot_a $ORIG_GOPATH/$dot_a
75+
done
76+
elif [[ $vendor || $update ]]; then
7577
pkg=$2
7678

7779
if [ "x${pkg}x" == "xx" ]; then

0 commit comments

Comments
 (0)