Commit 59d49f70 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Rename Git::Repository::Location to Git::Location

parent 565fdd63
......@@ -169,6 +169,7 @@ module QA
#
module Git
autoload :Repository, 'qa/git/repository'
autoload :Location, 'qa/git/location'
end
##
......
require 'uri'
require 'forwardable'
module QA
module Git
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
......@@ -4,8 +4,6 @@ require 'uri'
module QA
module Git
class Repository
autoload :Location, 'qa/git/repository/location'
include Scenario::Actable
def self.perform(*args)
......
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
describe QA::Git::Repository::Location do
describe QA::Git::Location do
describe '.parse' do
context 'when URI starts with ssh://' do
context 'when URI has port' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment