From 40d1466ce7aa657f529552c29fbce4cb4b7bdba5 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Thu, 7 Jan 2016 19:57:15 +0100 Subject: [PATCH] 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 Upstream-commit: 4c22c566e25ff2bc6fa80cd9627c59512a1f768d Component: engine --- components/engine/Makefile | 2 +- components/engine/hack/make.sh | 1 + components/engine/hack/make/validate-vendor | 27 +++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 components/engine/hack/make/validate-vendor diff --git a/components/engine/Makefile b/components/engine/Makefile index 17ab01b965..6bca1e7642 100644 --- a/components/engine/Makefile +++ b/components/engine/Makefile @@ -93,4 +93,4 @@ test-unit: build $(DOCKER_RUN_DOCKER) hack/make.sh test-unit validate: build - $(DOCKER_RUN_DOCKER) hack/make.sh validate-dco validate-gofmt validate-pkg validate-lint validate-test validate-toml validate-vet + $(DOCKER_RUN_DOCKER) hack/make.sh validate-dco validate-gofmt validate-pkg validate-lint validate-test validate-toml validate-vet validate-vendor diff --git a/components/engine/hack/make.sh b/components/engine/hack/make.sh index c87282b756..5aa044dddd 100755 --- a/components/engine/hack/make.sh +++ b/components/engine/hack/make.sh @@ -51,6 +51,7 @@ DEFAULT_BUNDLES=( validate-test validate-toml validate-vet + validate-vendor binary dynbinary diff --git a/components/engine/hack/make/validate-vendor b/components/engine/hack/make/validate-vendor new file mode 100644 index 0000000000..7c2cf33c66 --- /dev/null +++ b/components/engine/hack/make/validate-vendor @@ -0,0 +1,27 @@ +#!/bin/bash + +source "${MAKEDIR}/.validate" + +IFS=$'\n' +files=( $(validate_diff --diff-filter=ACMR --name-only -- 'hack/vendor.sh' 'hack/.vendor-helpers.sh' 'vendor/' || true) ) +unset IFS + +if [ ${#files[@]} -gt 0 ]; then + # We run vendor.sh to and see if we have a diff afterwards + ./hack/vendor.sh >/dev/null + # Let see if the working directory is clean + diffs="$(git status --porcelain -- vendor 2>/dev/null)" + if [ "$diffs" ]; then + { + echo 'The result of ./hack/vendor.sh differs' + echo + echo "$diffs" + echo + echo 'Please vendor your package with ./hack/vendor.sh.' + echo + } >&2 + false + else + echo 'Congratulations! All vendoring changes are done the right way.' + fi +fi