Skip to content

Commit

Permalink
Merge pull request #3469 from dependabot/updates-1280-remote-end-hung-up
Browse files Browse the repository at this point in the history
fix(Go mod): detect when remote end hangs up
  • Loading branch information
xlgmokha authored Apr 9, 2021
2 parents fc12b55 + 2bb2f9a commit dc12c50
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class GoModUpdater
].freeze

REPO_RESOLVABILITY_ERROR_REGEXES = [
/fatal: The remote end hung up unexpectedly/,
/repository '.+' not found/,
# (Private) module could not be fetched
/go: .*: git fetch .*: exit status 128/.freeze,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,30 @@
end
end

context "when the remote end hangs up unexpectedly" do
let(:dependency_name) { "github.com/spf13/viper" }
let(:dependency_version) { "v1.7.1" }
let(:dependency_previous_version) { "v1.7.1" }
let(:requirements) { [] }
let(:previous_requirements) { [] }
let(:exit_status) { double(status: 128, success?: false) }
let(:stderr) do
<<~ERROR
go: github.com/spf13/viper@v1.7.1 requires
github.com/grpc-ecosystem/grpc-gateway@v1.9.0 requires
gopkg.in/yaml.v2@v2.0.0-20170812160011-eb3733d160e7: invalid version: git fetch --unshallow -f origin in /opt/go/gopath/pkg/mod/cache/vcs/sha1: exit status 128:
fatal: The remote end hung up unexpectedly
ERROR
end

before do
allow(Open3).to receive(:capture3).and_call_original
allow(Open3).to receive(:capture3).with(anything, "go get -d").and_return(["", stderr, exit_status])
end

it { expect { subject }.to raise_error(Dependabot::DependencyFileNotResolvable, /The remote end hung up/) }
end

context "for an explicit indirect dependency" do
let(:project_name) { "indirect" }
let(:dependency_name) { "github.com/mattn/go-isatty" }
Expand Down

0 comments on commit dc12c50

Please sign in to comment.