mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Do not require replace rules to be added if there's no code-changes in the module. Note that changes in api/swagger.yaml may result in changes in generated code, but this should be checked separate from the swagger itself. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
51 lines
1.6 KiB
Bash
Executable File
51 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "${SCRIPTDIR}/.validate"
|
|
|
|
api_files=$(
|
|
validate_diff --diff-filter=ACMR --name-only -- \
|
|
'api/' \
|
|
':(exclude)api/README.md' \
|
|
':(exclude)api/swagger.yaml' \
|
|
':(exclude)api/docs/' \
|
|
|| true
|
|
)
|
|
|
|
client_files=$(validate_diff --diff-filter=ACMR --name-only -- 'client/' || true)
|
|
|
|
has_errors=0
|
|
|
|
cat go.mod
|
|
|
|
# Check if changes to ./api require a replace rule in go.mod
|
|
if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ -n "${api_files}" ]; then
|
|
echo "Detected changes in ./api directory, checking for replace rule..."
|
|
if ! go list -mod=readonly -m -json github.com/moby/moby/api | jq -e '.Replace'; then
|
|
echo >&2 "ERROR: Changes detected in ./api but go.mod is missing a replace rule for github.com/moby/moby/api"
|
|
echo >&2 "Please run ./hack/vendor.sh replace"
|
|
has_errors=1
|
|
else
|
|
echo "✓ Found replace rule for github.com/moby/moby/api"
|
|
fi
|
|
fi
|
|
|
|
# Check if changes to ./client require a replace rule in go.mod
|
|
if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ -n "${client_files}" ]; then
|
|
echo "Detected changes in ./client directory, checking for replace rule..."
|
|
if ! go list -mod=readonly -m -json github.com/moby/moby/client | jq -e '.Replace'; then
|
|
echo >&2 "ERROR: Changes detected in ./client but go.mod is missing a replace rule for github.com/moby/moby/client"
|
|
echo >&2 "Please run ./hack/vendor.sh replace"
|
|
has_errors=1
|
|
else
|
|
echo "✓ Found replace rule for github.com/moby/moby/client"
|
|
fi
|
|
fi
|
|
|
|
if [ $has_errors -eq 1 ]; then
|
|
exit 1
|
|
fi
|
|
|
|
echo "PASS: Module replace rules are correct"
|