diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-02-12 16:43:32 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-02-12 16:43:32 +0800 |
commit | bc2739a52ff9a5366d3d668ef0ee07e91974c540 (patch) | |
tree | 3feef5d1f12464d15c8c2140b32fc154f46d89ad /qa/qa/git/repository.rb | |
parent | 75984534f80b97d2bc7f05c24ce3e0cadb5b85a3 (diff) | |
download | gitlab-ce-bc2739a52ff9a5366d3d668ef0ee07e91974c540.tar.gz |
Adopt Git style URI
Diffstat (limited to 'qa/qa/git/repository.rb')
-rw-r--r-- | qa/qa/git/repository.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb index 8f999511d58..606fc66b4d5 100644 --- a/qa/qa/git/repository.rb +++ b/qa/qa/git/repository.rb @@ -1,3 +1,4 @@ +require 'cgi' require 'uri' module QA @@ -5,6 +6,19 @@ module QA class Repository include Scenario::Actable + # See: config/initializers/1_settings.rb + # Settings#build_gitlab_shell_ssh_path_prefix + def self.parse_uri(git_uri) + if git_uri.start_with?('ssh://') + URI.parse(git_uri) + else + *rest, path = git_uri.split(':') + # Host cannot have : so we'll need to escape it + user_host = rest.join('%3A').sub(/\A\[(.+)\]\z/, '\1') + URI.parse("ssh://#{user_host}/#{path}") + end + end + def self.perform(*args) Dir.mktmpdir do |dir| Dir.chdir(dir) { super } |