Merge pull request #104995 from pohly/pin-dependencies-to-fork

pin-dependency.sh: enhance forking of a dependency
This commit is contained in:
Kubernetes Prow Robot 2021-09-15 08:56:31 -07:00 committed by GitHub
commit f570b940f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,6 +104,18 @@ for repo in $(kube::util::list_staging_repos); do
go mod edit -require "${dep}@${rev}"
go mod edit -replace "${dep}=${replacement}@${rev}"
fi
# When replacing with a fork, always add a replace statement in all go.mod
# files (not just the root of the staging repos!) because there might be
# indirect dependencies on the fork.
#
# This is excessive, but the resulting commit should never be merged, so it
# isn't that important to get this exactly right.
if [ "${replacement}" != "${dep}" ]; then
find . -name go.mod -print | while read -r modfile; do
(cd "$(dirname "${modfile}")" && go mod edit -replace "${dep}=${replacement}@${rev}")
done
fi
popd >/dev/null 2>&1
done