Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Go mod): detect when remote end hangs up #3469

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/[email protected] requires
github.com/grpc-ecosystem/[email protected] requires
gopkg.in/[email protected]: 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