mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
Guard against merging non-canonical replace directives
This commit is contained in:
parent
3f823c0daa
commit
9cb283796f
@ -65,6 +65,20 @@ if [[ -n "${outdated}" ]]; then
|
||||
echo "${outdated}"
|
||||
fi
|
||||
|
||||
noncanonical=$(go list -m -json all | jq -r "
|
||||
select(.Replace.Version != null) |
|
||||
select(.Path != .Replace.Path) |
|
||||
select(.Path) |
|
||||
\" \(.Path) is replaced with \(.Replace.Path)\"
|
||||
")
|
||||
if [[ -n "${noncanonical}" ]]; then
|
||||
echo ""
|
||||
echo "These modules are pinned to non-canonical repos."
|
||||
echo "Revert to using the canonical repo for these modules before merge"
|
||||
echo ""
|
||||
echo "${noncanonical}"
|
||||
fi
|
||||
|
||||
unused=$(comm -23 \
|
||||
<(go mod edit -json | jq -r '.Replace[] | select(.New.Version != null) | .Old.Path' | sort) \
|
||||
<(go list -m -json all | jq -r .Path | sort))
|
||||
@ -74,9 +88,10 @@ if [[ -n "${unused}" ]]; then
|
||||
echo "${unused}" | xargs -L 1 echo 'GO111MODULE=on go mod edit -dropreplace'
|
||||
fi
|
||||
|
||||
if [[ -n "${unused}${outdated}" ]]; then
|
||||
if [[ -n "${unused}${outdated}${noncanonical}" ]]; then
|
||||
rc=1
|
||||
else
|
||||
echo "All pinned versions of checked dependencies match their preferred version."
|
||||
fi
|
||||
|
||||
echo "All pinned versions of checked dependencies match their preferred version."
|
||||
exit $rc
|
||||
|
Loading…
Reference in New Issue
Block a user