summaryrefslogtreecommitdiff
path: root/qa/qa/git
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-02-20 12:45:04 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-09 10:36:27 +0100
commit7d20e47622c9a6e0a780bdbe9b53c8890c00deba (patch)
tree9650b8b1d1edde4b92a748a9ee9ab5c4e4c1ba5c /qa/qa/git
parent72e940df2c24ab80056dfe296011c7a44ebdf3f0 (diff)
downloadgitlab-ce-7d20e47622c9a6e0a780bdbe9b53c8890c00deba.tar.gz
Add GitLab QA integrations tests to GitLab CE / EE
Diffstat (limited to 'qa/qa/git')
-rw-r--r--qa/qa/git/repository.rb71
1 files changed, 71 insertions, 0 deletions
diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb
new file mode 100644
index 00000000000..b9e199000d6
--- /dev/null
+++ b/qa/qa/git/repository.rb
@@ -0,0 +1,71 @@
+require 'uri'
+
+module QA
+ module Git
+ class Repository
+ include Scenario::Actable
+
+ def self.perform(*args)
+ Dir.mktmpdir do |dir|
+ Dir.chdir(dir) { super }
+ end
+ end
+
+ def location=(address)
+ @location = address
+ @uri = URI(address)
+ end
+
+ def username=(name)
+ @username = name
+ @uri.user = name
+ end
+
+ def password=(pass)
+ @password = pass
+ @uri.password = pass
+ end
+
+ def use_default_credentials
+ self.username = Runtime::User.name
+ self.password = Runtime::User.password
+ end
+
+ def clone(opts = '')
+ `git clone #{opts} #{@uri.to_s} ./`
+ end
+
+ def shallow_clone
+ clone('--depth 1')
+ end
+
+ def configure_identity(name, email)
+ `git config user.name #{name}`
+ `git config user.email #{email}`
+ end
+
+ def commit_file(name, contents, message)
+ add_file(name, contents)
+ commit(message)
+ end
+
+ def add_file(name, contents)
+ File.write(name, contents)
+
+ `git add #{name}`
+ end
+
+ def commit(message)
+ `git commit -m "#{message}"`
+ end
+
+ def push_changes(branch = 'master')
+ `git push #{@uri.to_s} #{branch}`
+ end
+
+ def commits
+ `git log --oneline`.split("\n")
+ end
+ end
+ end
+end