2017-04-21 09:23:45 +00:00
|
|
|
#!/usr/bin/env bash
|
2017-02-01 23:49:32 +00:00
|
|
|
set -o errexit
|
|
|
|
set -o pipefail
|
|
|
|
set -o nounset
|
|
|
|
|
2018-01-09 20:46:04 +00:00
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; export SCRIPT_DIR
|
|
|
|
source "${SCRIPT_DIR}/.validate"
|
2017-02-01 23:49:32 +00:00
|
|
|
|
2017-07-06 14:28:13 +00:00
|
|
|
vendor_dir="./vendor/"
|
|
|
|
IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- ${vendor_dir} || true) )
|
2017-02-01 23:49:32 +00:00
|
|
|
|
2017-07-06 14:28:13 +00:00
|
|
|
if [[ ${#files[@]} -gt 0 ]]; then
|
2018-01-09 20:46:04 +00:00
|
|
|
# We run dep install to and see if we have a diff afterwards
|
2017-07-06 14:28:13 +00:00
|
|
|
echo "checking ${vendor_dir} for unintentional changes..."
|
2018-01-09 20:46:04 +00:00
|
|
|
|
|
|
|
dep ensure -v
|
|
|
|
(${SCRIPT_DIR}/prune-dep.sh)
|
|
|
|
|
2017-07-06 14:28:13 +00:00
|
|
|
# Let see if the working directory is clean
|
|
|
|
diffs="$(git status --porcelain -- ${vendor_dir} 2>/dev/null)"
|
|
|
|
if [[ "$diffs" ]]; then
|
|
|
|
{
|
2018-01-09 20:46:04 +00:00
|
|
|
echo "The result of 'dep ensure' for vendor directory '${vendor_dir}' differs"
|
2017-07-06 14:28:13 +00:00
|
|
|
echo
|
|
|
|
echo "$diffs"
|
|
|
|
echo
|
2018-01-09 20:46:04 +00:00
|
|
|
echo 'Please vendor your package(s) with dep.'
|
2017-07-06 14:28:13 +00:00
|
|
|
echo
|
|
|
|
} >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
fi
|
2017-02-01 23:49:32 +00:00
|
|
|
|
|
|
|
echo 'Congratulations! All vendoring changes are done the right way.'
|