Skip to content

Commit

Permalink
Merge pull request etcd-io#19042 from ivanvc/update-go-mod-tidy-pass-…
Browse files Browse the repository at this point in the history
…to-use-diff

scripts: simplify mod tidy pass
  • Loading branch information
ahrtr authored Dec 12, 2024
2 parents fe14e24 + 9d8f2fa commit f03dee9
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -628,34 +628,11 @@ function release_pass {
}

function mod_tidy_for_module {
# Watch for upstream solution: https://github.com/golang/go/issues/27005
local tmpModDir
tmpModDir=$(mktemp -d -t 'tmpModDir.XXXXXX')
run cp "./go.mod" "${tmpModDir}" || return 2

# Guarantees keeping go.sum minimal
# If this is causing too much problems, we should
# stop controlling go.sum at all.
rm go.sum
run go mod tidy || return 2

set +e
local tmpFileGoModInSync
diff -C 5 "${tmpModDir}/go.mod" "./go.mod"
tmpFileGoModInSync="$?"

# Bring back initial state
mv "${tmpModDir}/go.mod" "./go.mod"

if [ "${tmpFileGoModInSync}" -ne 0 ]; then
log_error "${PWD}/go.mod is not in sync with 'go mod tidy'"
return 255
fi
set -e
run go mod tidy -diff
}

function mod_tidy_pass {
run_for_modules mod_tidy_for_module
run_for_modules generic_checker mod_tidy_for_module
}

function proto_annotations_pass {
Expand Down

0 comments on commit f03dee9

Please sign in to comment.