Browse code

Add a validate-vendor script

Makes sure that if ./hack/vendor.sh has been updated, it has been used
to update the vendor folder.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Vincent Demeester authored on 2016/01/08 03:57:15
Showing 3 changed files
... ...
@@ -93,4 +93,4 @@ test-unit: build
93 93
 	$(DOCKER_RUN_DOCKER) hack/make.sh test-unit
94 94
 
95 95
 validate: build
96
-	$(DOCKER_RUN_DOCKER) hack/make.sh validate-dco validate-gofmt validate-pkg validate-lint validate-test validate-toml validate-vet
96
+	$(DOCKER_RUN_DOCKER) hack/make.sh validate-dco validate-gofmt validate-pkg validate-lint validate-test validate-toml validate-vet validate-vendor
... ...
@@ -51,6 +51,7 @@ DEFAULT_BUNDLES=(
51 51
 	validate-test
52 52
 	validate-toml
53 53
 	validate-vet
54
+	validate-vendor
54 55
 
55 56
 	binary
56 57
 	dynbinary
57 58
new file mode 100644
... ...
@@ -0,0 +1,27 @@
0
+#!/bin/bash
1
+
2
+source "${MAKEDIR}/.validate"
3
+
4
+IFS=$'\n'
5
+files=( $(validate_diff --diff-filter=ACMR --name-only -- 'hack/vendor.sh' 'hack/.vendor-helpers.sh' 'vendor/' || true) ) 
6
+unset IFS
7
+
8
+if [ ${#files[@]} -gt 0 ]; then
9
+	# We run vendor.sh to and see if we have a diff afterwards
10
+	./hack/vendor.sh >/dev/null
11
+	# Let see if the working directory is clean
12
+	diffs="$(git status --porcelain -- vendor 2>/dev/null)"
13
+	if [ "$diffs" ]; then
14
+		{
15
+			echo 'The result of ./hack/vendor.sh differs'
16
+			echo
17
+			echo "$diffs"
18
+			echo
19
+			echo 'Please vendor your package with ./hack/vendor.sh.'
20
+			echo
21
+		} >&2
22
+		false
23
+	else
24
+		echo 'Congratulations! All vendoring changes are done the right way.'
25
+	fi
26
+fi