Skip to content

Commit

Permalink
Merge pull request #2830 from dependabot/fatih/silently-fail-go-mod-tidy
Browse files Browse the repository at this point in the history
go_modules: don't raise error for go mod tidy
  • Loading branch information
feelepxyz authored Dec 10, 2020
2 parents 8d3339d + aa67f7d commit 8c45d5a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,15 @@ def update_files # rubocop:disable Metrics/AbcSize
def run_go_mod_tidy
return unless tidy?

# NOTE(arslan): use `go mod tidy -e` once Go 1.16 is out:
# https://github.com/golang/go/commit/3aa09489ab3aa13a3ac78b1ff012b148ffffe367
command = "go mod tidy"
_, stderr, status = Open3.capture3(ENVIRONMENT, command)
handle_subprocess_error(stderr) unless status.success?

# we explicitly don't raise an error for 'go mod tidy' and silently
# continue here. `go mod tidy` shouldn't block updating versions
# because there are some edge cases where it's OK to fail (such as
# generated files not available yet to us).
Open3.capture3(ENVIRONMENT, command)
end

def run_go_vendor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,16 @@
# OpenAPIV2 has been renamed to openapiv2 in this version
let(:dependency_version) { "v0.5.1" }

it "raises a DependencyFileNotResolvable error" do
error_class = Dependabot::DependencyFileNotResolvable
# NOTE: We explitly don't want to raise a resolvability error from go mod tidy
it "does not raises a DependencyFileNotResolvable error" do
expect { updater.updated_go_sum_content }.
to raise_error(error_class) do |error|
expect(error.message).to include("googleapis/gnostic/OpenAPIv2")
end
to_not raise_error(Dependabot::DependencyFileNotResolvable)
end

it "updates the go.mod" do
expect(updater.updated_go_mod_content).to include(
%(github.com/googleapis/gnostic v0.5.1 // indirect\n)
)
end
end
end
Expand Down

0 comments on commit 8c45d5a

Please sign in to comment.