summaryrefslogtreecommitdiff
path: root/qa/qa/git
diff options
context:
space:
mode:
authorMark Lapierre <mlapierre@gitlab.com>2018-10-23 14:54:00 -0400
committerMark Lapierre <mlapierre@gitlab.com>2018-11-07 12:16:17 -0500
commit765ca40d65c6644d2158eb04898a0f3d6e316e31 (patch)
tree171da745cea50c3da1cdcd2f03b5fe58c3d9b1af /qa/qa/git
parent912741cfea06ead8dad95d20f2f0adb955a55732 (diff)
downloadgitlab-ce-765ca40d65c6644d2158eb04898a0f3d6e316e31.tar.gz
Add e2e test of push over SSH over Git protocol v2ml-qa-git-protocol-v2-spec
Adds a new end-to-end test to check that Git protocol v2 can be used to push over SSH. Includes a change in Git::Repository to use Runtime::Env.debug? to enable logging instead of .verbose?
Diffstat (limited to 'qa/qa/git')
-rw-r--r--qa/qa/git/repository.rb26
1 files changed, 24 insertions, 2 deletions
diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb
index 27a88534258..7f959441dac 100644
--- a/qa/qa/git/repository.rb
+++ b/qa/qa/git/repository.rb
@@ -109,6 +109,28 @@ module QA
known_hosts_file.close(true)
end
+ def push_with_git_protocol(version, file_name, file_content, commit_message = 'Initial commit')
+ self.git_protocol = version
+ add_file(file_name, file_content)
+ commit(commit_message)
+ push_changes
+
+ fetch_supported_git_protocol
+ end
+
+ def git_protocol=(value)
+ raise ArgumentError, "Please specify the protocol you would like to use: 0, 1, or 2" unless %w[0 1 2].include?(value.to_s)
+
+ run("git config protocol.version #{value}")
+ 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'
+ end
+
private
attr_reader :uri, :username, :password, :known_hosts_file, :private_key_file
@@ -117,8 +139,8 @@ module QA
!private_key_file.nil?
end
- def run(command_str)
- command = [env_vars, command_str, '2>&1'].compact.join(' ')
+ def run(command_str, *extra_env)
+ command = [env_vars, *extra_env, command_str, '2>&1'].compact.join(' ')
Runtime::Logger.debug "Git: command=[#{command}]"
output, _ = Open3.capture2(command)