From 354abbcb92cb31ce15d02eaa03f178a8d7dfb7b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Thu, 6 Nov 2025 23:42:03 +0100 Subject: [PATCH 1/2] hack/vendor: Allow to specify ref to dropreplace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- hack/vendor.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hack/vendor.sh b/hack/vendor.sh index 61fc0d8524..00e31b21be 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -42,15 +42,21 @@ replace() ( dropreplace() ( set -x + ref=$1 + if [ -z "$ref" ]; then + ref=master + fi + + ref=$(git rev-parse "$ref") go mod edit -dropreplace=github.com/moby/moby/api -dropreplace=github.com/moby/moby/client go mod edit -modfile client/go.mod -dropreplace=github.com/moby/moby/api - go mod edit -modfile client/go.mod -require='github.com/moby/moby/api@master' + go mod edit -modfile client/go.mod -require="github.com/moby/moby/api@$ref" (cd client; go mod tidy) go mod edit \ - -require='github.com/moby/moby/api@master' \ - -require='github.com/moby/moby/client@master' + -require="github.com/moby/moby/api@$ref" \ + -require="github.com/moby/moby/client@$ref" go mod tidy go mod vendor ) @@ -69,7 +75,7 @@ case "$1" in tidy) tidy ;; vendor) vendor ;; replace) replace ;; - dropreplace) dropreplace ;; + dropreplace) dropreplace "$2" ;; ""|all) tidy && vendor ;; *) help ;; esac From 05f9988fc88bd22c11ecc931ebf405d18ad7ca3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Wed, 17 Dec 2025 15:53:23 +0100 Subject: [PATCH 2/2] hack/vendor/dropreplace: Make the auto-ref pick more reliable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dropreplace now accepts an optional argument that allows to manually specify a git ref to use for the modules. It's not required though and if not present it will default to a master branch from the upstream (preferred) or origin remote. This is much more reliable than "module@master" which for some reason tends to not resolve to the actual latest commit on the master branch. Signed-off-by: Paweł Gronowski --- hack/vendor.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/hack/vendor.sh b/hack/vendor.sh index 00e31b21be..91305c34a5 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -44,7 +44,20 @@ dropreplace() ( set -x ref=$1 if [ -z "$ref" ]; then - ref=master + # module@master not always results in the actual latest commit on the + # master branch. + # Use the actual branch from the upstream or origin remote. + for r in "upstream" "origin"; do + if git remote get-url "$r" >/dev/null 2>&1; then + ref="$r/master" + break + fi + done + if [ -z "$ref" ]; then + echo "No valid master ref found" >&2 + exit 1 + fi + echo "Using $ref" >&2 fi ref=$(git rev-parse "$ref") @@ -66,7 +79,7 @@ help() { echo " - tidy: run go mod tidy" echo " - vendor: run go mod vendor" echo " - replace: run go mod edit replace for local modules" - echo " - dropreplace: run go mod edit dropreplace for local modules" + echo " - dropreplace []: remove replace rules and update the api and client modules to the provided ref (defaults to upstream/master)" echo " - all: run tidy && vendor" echo " - help: show this help" }