Skip to content

Commit aaa8802

Browse files
committed
Prune unnecessary replace directives from staging go.mod files
1 parent 9e83e6d commit aaa8802

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

hack/update-vendor.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,19 @@ $(go mod why ${loopback_deps})"
243243

244244
# prune unused pinned replace directives
245245
comm -23 \
246-
<(go mod edit -json | jq -r '.Replace[] | select(.Old.Path == .New.Path) | select(.New.Version != null) | .Old.Path' | sort) \
246+
<(go mod edit -json | jq -r '.Replace[] | .Old.Path' | sort) \
247247
<(go list -m -json all | jq -r .Path | sort) |
248248
xargs -L 1 -I {} echo "-dropreplace={}" |
249249
xargs -L 100 go mod edit -fmt
250250

251+
# prune replace directives that pin to the naturally selected version
252+
go list -m -json all |
253+
jq -r 'select(.Replace != null) |
254+
select(.Path == .Replace.Path) |
255+
select(.Version == .Replace.Version) |
256+
"-dropreplace \(.Replace.Path)"' |
257+
xargs -L 100 go mod edit -fmt
258+
251259
popd >/dev/null 2>&1
252260
done
253261
echo "=== tidying root" >> "${LOG_FILE}"

0 commit comments

Comments
 (0)