Browse code

Fix vendor validation

Previously adding files to vendor/ without adding to vendor.conf would not fail the
validation.

Also be consistent with indentation and use tabs.

Signed-off-by: Daniel Nephin <dnephin@gmail.com>

Daniel Nephin authored on 2018/02/03 03:43:36
Showing 1 changed files
... ...
@@ -9,9 +9,13 @@ validate_vendor_diff(){
9 9
 	unset IFS
10 10
 
11 11
 	if [ ${#files[@]} -gt 0 ]; then
12
-		# We run vndr to and see if we have a diff afterwards
12
+		# Remove vendor/ first so  that anything not included in vendor.conf will
13
+		# cause the validation to fail. archive/tar is a special case, see vendor.conf
14
+		# for details.
15
+		ls -d vendor/* | grep -v vendor/archive | xargs rm -rf
16
+		# run vndr to recreate vendor/
13 17
 		vndr
14
-		# Let see if the working directory is clean
18
+		# check if any files have changed
15 19
 		diffs="$(git status --porcelain -- vendor 2>/dev/null)"
16 20
 		if [ "$diffs" ]; then
17 21
 			{
... ...
@@ -34,17 +38,17 @@ validate_vendor_diff(){
34 34
 # 1. make sure all the vendored packages are used
35 35
 # 2. make sure all the packages contain license information (just warning, because it can cause false-positive)
36 36
 validate_vendor_used() {
37
-    pkgs=$(mawk '/^[a-zA-Z0-9]/ { print $1 }' < vendor.conf)
38
-    for f in $pkgs; do
37
+	pkgs=$(mawk '/^[a-zA-Z0-9]/ { print $1 }' < vendor.conf)
38
+	for f in $pkgs; do
39 39
 	if ls -d vendor/$f  > /dev/null 2>&1; then
40
-	    found=$(find vendor/$f -iregex '.*LICENSE.*' -or -iregex '.*COPYRIGHT.*' -or -iregex '.*COPYING.*' | wc -l)
41
-	    if [ $found -eq 0 ]; then
40
+		found=$(find vendor/$f -iregex '.*LICENSE.*' -or -iregex '.*COPYRIGHT.*' -or -iregex '.*COPYING.*' | wc -l)
41
+		if [ $found -eq 0 ]; then
42 42
 		echo "WARNING: could not find copyright information for $f"
43
-	    fi
43
+		fi
44 44
 	else
45
-	    echo "WARNING: $f is vendored but unused"
45
+		echo "WARNING: $f is vendored but unused"
46 46
 	fi
47
-    done
47
+	done
48 48
 }
49 49
 
50 50
 validate_vendor_diff