diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-02-12 23:25:18 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-02-12 23:49:09 +0800 |
commit | 565fdd63cf49c266c7a6a2a0d2a843339a9d30e6 (patch) | |
tree | 3567619e22cdf16df541c67aaf6f7809d8f4e14b /qa/qa/git | |
parent | 2f34ef34fa230c1954e47504cd8ead1a6ab019fe (diff) | |
download | gitlab-ce-565fdd63cf49c266c7a6a2a0d2a843339a9d30e6.tar.gz |
Rearrange the test structure and introduce
a new repository location class.
Diffstat (limited to 'qa/qa/git')
-rw-r--r-- | qa/qa/git/repository.rb | 15 | ||||
-rw-r--r-- | qa/qa/git/repository/location.rb | 41 |
2 files changed, 43 insertions, 13 deletions
diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb index 606fc66b4d5..903d292b69c 100644 --- a/qa/qa/git/repository.rb +++ b/qa/qa/git/repository.rb @@ -4,20 +4,9 @@ require 'uri' module QA module Git class Repository - include Scenario::Actable + autoload :Location, 'qa/git/repository/location' - # 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 + include Scenario::Actable def self.perform(*args) Dir.mktmpdir do |dir| diff --git a/qa/qa/git/repository/location.rb b/qa/qa/git/repository/location.rb new file mode 100644 index 00000000000..dce8327ce82 --- /dev/null +++ b/qa/qa/git/repository/location.rb @@ -0,0 +1,41 @@ +require 'uri' +require 'forwardable' + +module QA + module Git + class Repository + class Location + extend Forwardable + + attr_reader :git_uri, :uri + def_delegators :@uri, :user, :host, :path + + # See: config/initializers/1_settings.rb + # Settings#build_gitlab_shell_ssh_path_prefix + def self.parse(git_uri) + if git_uri.start_with?('ssh://') + new(git_uri, 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') + new(git_uri, URI.parse("ssh://#{user_host}/#{path}")) + end + end + + def initialize(git_uri, uri) + @git_uri = git_uri + @uri = uri + end + + def scheme + uri.scheme || 'ssh' + end + + def port + uri.port || 22 + end + end + end + end +end |