Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bc2739a5
Commit
bc2739a5
authored
Feb 12, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adopt Git style URI
parent
75984534
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
1 deletion
+67
-1
qa/qa/git/repository.rb
qa/qa/git/repository.rb
+14
-0
qa/qa/specs/features/cicd/pull_with_deploy_key_spec.rb
qa/qa/specs/features/cicd/pull_with_deploy_key_spec.rb
+1
-1
qa/spec/git/repository_spec.rb
qa/spec/git/repository_spec.rb
+52
-0
No files found.
qa/qa/git/repository.rb
View file @
bc2739a5
require
'cgi'
require
'uri'
require
'uri'
module
QA
module
QA
...
@@ -5,6 +6,19 @@ module QA
...
@@ -5,6 +6,19 @@ module QA
class
Repository
class
Repository
include
Scenario
::
Actable
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
)
def
self
.
perform
(
*
args
)
Dir
.
mktmpdir
do
|
dir
|
Dir
.
mktmpdir
do
|
dir
|
Dir
.
chdir
(
dir
)
{
super
}
Dir
.
chdir
(
dir
)
{
super
}
...
...
qa/qa/specs/features/cicd/pull_with_deploy_key_spec.rb
View file @
bc2739a5
...
@@ -45,7 +45,7 @@ module QA
...
@@ -45,7 +45,7 @@ module QA
repository_location
repository_location
end
end
repository_uri
=
URI
.
parse
(
repository_url
)
repository_uri
=
Git
::
Repository
.
parse_uri
(
repository_url
)
gitlab_ci
=
gitlab_ci
=
<<~
YAML
<<~
YAML
...
...
qa/spec/git/repository_spec.rb
0 → 100644
View file @
bc2739a5
describe
QA
::
Git
::
Repository
do
describe
'.parse_uri'
do
context
'when URI starts with ssh://'
do
context
'when URI has port'
do
it
'parses correctly'
do
uri
=
described_class
.
parse_uri
(
'ssh://git@qa.test:2222/sandbox/qa/repo.git'
)
expect
(
uri
.
user
).
to
eq
(
'git'
)
expect
(
uri
.
host
).
to
eq
(
'qa.test'
)
expect
(
uri
.
port
).
to
eq
(
2222
)
expect
(
uri
.
path
).
to
eq
(
'/sandbox/qa/repo.git'
)
end
end
context
'when URI does not have port'
do
it
'parses correctly'
do
uri
=
described_class
.
parse_uri
(
'ssh://git@qa.test/sandbox/qa/repo.git'
)
expect
(
uri
.
user
).
to
eq
(
'git'
)
expect
(
uri
.
host
).
to
eq
(
'qa.test'
)
expect
(
uri
.
path
).
to
eq
(
'/sandbox/qa/repo.git'
)
end
end
end
context
'when URI does not start with ssh://'
do
context
'when host does not have colons'
do
it
'parses correctly'
do
uri
=
described_class
.
parse_uri
(
'git@qa.test:sandbox/qa/repo.git'
)
expect
(
uri
.
user
).
to
eq
(
'git'
)
expect
(
uri
.
host
).
to
eq
(
'qa.test'
)
expect
(
uri
.
path
).
to
eq
(
'/sandbox/qa/repo.git'
)
end
end
context
'when host has a colon'
do
it
'parses correctly'
do
uri
=
described_class
.
parse_uri
(
'[git@qa:test]:sandbox/qa/repo.git'
)
expect
(
uri
.
user
).
to
eq
(
'git'
)
expect
(
uri
.
host
).
to
eq
(
'qa%3Atest'
)
expect
(
uri
.
path
).
to
eq
(
'/sandbox/qa/repo.git'
)
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment