From d399073695278888e1ce1c9a7d3a864811504924 Mon Sep 17 00:00:00 2001 From: Indradhanush Gupta Date: Sun, 20 Oct 2019 16:34:52 +0530 Subject: [PATCH] Add script to check for uncommitted vendor changes in build --- .travis.yml | 2 +- scripts/check-uncommitted-vendor-files.sh | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 scripts/check-uncommitted-vendor-files.sh diff --git a/.travis.yml b/.travis.yml index 3e1abfe3..cdd82abd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,4 @@ before_install: - cd $HOME/gopath/src/github.com/wtfutil/wtf - export GOPROXY="https://gocenter.io" && export GO111MODULE=on -script: go get ./... && go test -v github.com/wtfutil/wtf/... +script: go get ./... && ./scripts/check-uncommitted-vendor-files.sh && go test -v github.com/wtfutil/wtf/... diff --git a/scripts/check-uncommitted-vendor-files.sh b/scripts/check-uncommitted-vendor-files.sh new file mode 100755 index 00000000..780b663a --- /dev/null +++ b/scripts/check-uncommitted-vendor-files.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -euo pipefail + +GOPROXY="https://gocenter.io" GOSUMDB=off GO111MODULE=on go mod tidy + +untracked_files=$(git ls-files --others --exclude-standard | wc -l) + +diff_stat=$(git diff --shortstat) + +if [[ "${untracked_files}" -ne 0 || -n "${diff_stat}" ]]; then + echo 'Untracked or diff in tracked vendor files found. Please run "go mod tidy" and commit the changes' + exit 1 +fi