summaryrefslogtreecommitdiff
path: root/qa/qa/git/repository.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/git/repository.rb')
-rw-r--r--qa/qa/git/repository.rb35
1 files changed, 32 insertions, 3 deletions
diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb
index 035946b8471..512653e8c4a 100644
--- a/qa/qa/git/repository.rb
+++ b/qa/qa/git/repository.rb
@@ -59,6 +59,10 @@ module QA
self.username, self.password = default_credentials
end
+ def use_default_identity
+ configure_identity('GitLab QA', 'root@gitlab.com')
+ end
+
def clone(opts = '')
clone_result = run("git clone #{opts} #{uri} ./", max_attempts: 3)
return clone_result.response unless clone_result.success?
@@ -122,8 +126,12 @@ module QA
run("git rev-parse --abbrev-ref HEAD").to_s
end
- def push_changes(branch = 'master')
- run("git push #{uri} #{branch}", max_attempts: 3).to_s
+ def push_changes(branch = 'master', push_options: nil)
+ cmd = ['git push']
+ cmd << push_options_hash_to_string(push_options)
+ cmd << uri
+ cmd << branch
+ run(cmd.compact.join(' '), max_attempts: 3).to_s
end
def push_all_branches
@@ -205,6 +213,10 @@ module QA
run("cat #{file}").to_s
end
+ def delete_netrc
+ File.delete(netrc_file_path) if File.exist?(netrc_file_path)
+ end
+
private
attr_reader :uri, :username, :password, :known_hosts_file,
@@ -216,7 +228,7 @@ module QA
alias_method :to_s, :response
def success?
- exitstatus == 0
+ exitstatus == 0 && !response.include?('Error encountered')
end
end
@@ -293,6 +305,23 @@ module QA
@tmp_home_dir ||= File.join(Dir.tmpdir, "qa-netrc-credentials", $$.to_s)
end
+ def push_options_hash_to_string(opts)
+ return if opts.nil?
+
+ prefix = "-o merge_request"
+ opts.each_with_object([]) do |(key, value), options|
+ if value.is_a?(Array)
+ value.each do |item|
+ options << "#{prefix}.#{key}=\"#{item}\""
+ end
+ elsif value == true
+ options << "#{prefix}.#{key}"
+ else
+ options << "#{prefix}.#{key}=\"#{value}\""
+ end
+ end.join(' ')
+ end
+
def netrc_file_path
@netrc_file_path ||= File.join(tmp_home_dir, '.netrc')
end