Skip to content

Commit

Permalink
The go.work.sum don't influence the dependencies resolution
Browse files Browse the repository at this point in the history
If it's not needed. If the file isn't empty after the update, it should
be committed.
  • Loading branch information
cardil committed Sep 21, 2023
1 parent c4a34c3 commit 21a2ed9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 174 deletions.
173 changes: 0 additions & 173 deletions go.work.sum

This file was deleted.

19 changes: 19 additions & 0 deletions library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,26 @@ function foreach_go_module() {
# global env var: FLOATING_DEPS
# --upgrade will set GOPROXY to direct unless it is already set.
function go_update_deps() {
# The go.work.sum will be truncated if it exists. This is to allow the
# `go mod tidy` to resolve the dependencies, without the influence of the
# sums from the workspace.
__clean_goworksum_if_exists
foreach_go_module __go_update_deps_for_module "$@"
__remove_goworksum_if_empty
}

function __clean_goworksum_if_exists() {
if [ -f "$REPO_ROOT_DIR/go.work.sum" ]; then
echo "=== Cleaning the go.work.sum file"
true > "$REPO_ROOT_DIR/go.work.sum"
fi
}

function __remove_goworksum_if_empty() {
if ! [ -s "$REPO_ROOT_DIR/go.work.sum" ]; then
echo "=== Removing empty go.work.sum"
rm -f "$REPO_ROOT_DIR/go.work.sum"
fi
}

function __go_update_deps_for_module() {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/update_deps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestUpdateDeps(t *testing.T) {
tcs := []testCase{{
name: "go_update_deps --unknown",
retcode: retcode(232),
stdout: lines("=== Update Deps for Golang module: knative.dev/hack"),
stdout: []check{contains("=== Update Deps for Golang module: knative.dev/hack")},
stderr: []check{contains("unknown option --unknown")},
}, {
name: "go_update_deps",
Expand Down

0 comments on commit 21a2ed9

Please sign in to comment.