diff options
Diffstat (limited to 'qa/qa/git/repository.rb')
-rw-r--r-- | qa/qa/git/repository.rb | 26 |
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) |