summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qa/qa/git/repository.rb10
-rw-r--r--qa/spec/git/repository_spec.rb4
2 files changed, 8 insertions, 6 deletions
diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb
index 0aa94101098..e6e1a618405 100644
--- a/qa/qa/git/repository.rb
+++ b/qa/qa/git/repository.rb
@@ -150,10 +150,12 @@ module QA
end
def fetch_supported_git_protocol
- # ls-remote is one command known to respond to Git protocol v2 so we use
- # it to get output including the version reported via Git tracing
- output = run("git ls-remote #{uri}", "GIT_TRACE_PACKET=1")
- output[/git< version (\d+)/, 1] || 'unknown'
+ # The git protocol must advertise it's version in the headers
+ # exchanged during the initial handshake. GIT_TRACE_CURL provides
+ # the header data and then GIT_TRACE_CURL_NOT_DATA ignores the
+ # extraneous data to keep return size down.
+ result = run("git ls-remote #{uri}", "GIT_TRACE_CURL=1 GIT_TRACE_CURL_NO_DATA=1")
+ result.response[/Git-Protocol: version=(\d+)/, 1] || 'unknown'
end
def try_add_credentials_to_netrc
diff --git a/qa/spec/git/repository_spec.rb b/qa/spec/git/repository_spec.rb
index 62c81050bd9..d8200686f44 100644
--- a/qa/spec/git/repository_spec.rb
+++ b/qa/spec/git/repository_spec.rb
@@ -68,12 +68,12 @@ describe QA::Git::Repository do
describe '#fetch_supported_git_protocol' do
it "reports the detected version" do
- expect(repository).to receive(:run).and_return("packet: git< version 2")
+ expect(repository).to receive(:run).and_return("=> Send header: Git-Protocol: version=2")
expect(repository.fetch_supported_git_protocol).to eq('2')
end
it 'reports unknown if version is unknown' do
- expect(repository).to receive(:run).and_return("packet: git< version -1")
+ expect(repository).to receive(:run).and_return("=> Send header: Git-Protocol: version=-1")
expect(repository.fetch_supported_git_protocol).to eq('unknown')
end