Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GitLab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
projects.thm.de
GitLab
Commits
150c3637
Commit
150c3637
authored
Feb 17, 2017
by
Jan Christophersen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the username of the current user to the HTTP(S) clone URL
parent
3589cc06
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
46 additions
and
9 deletions
+46
-9
app/helpers/button_helper.rb
app/helpers/button_helper.rb
+1
-1
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+1
-1
app/models/project.rb
app/models/project.rb
+8
-2
changelogs/unreleased/1937-https-clone-url-username.yml
changelogs/unreleased/1937-https-clone-url-username.yml
+4
-0
features/steps/explore/projects.rb
features/steps/explore/projects.rb
+1
-1
spec/features/admin/admin_disables_git_access_protocol_spec.rb
...features/admin/admin_disables_git_access_protocol_spec.rb
+1
-1
spec/features/projects/developer_views_empty_project_instructions_spec.rb
...ojects/developer_views_empty_project_instructions_spec.rb
+9
-3
spec/models/project_spec.rb
spec/models/project_spec.rb
+21
-0
No files found.
app/helpers/button_helper.rb
View file @
150c3637
...
...
@@ -34,7 +34,7 @@ def http_clone_button(project, placement = 'right', append_link: true)
content_tag
(
append_link
?
:a
:
:span
),
protocol
,
class:
klass
,
href:
(
project
.
http_url_to_repo
if
append_link
),
href:
(
project
.
http_url_to_repo
(
current_user
)
if
append_link
),
data:
{
html:
true
,
placement:
placement
,
...
...
app/helpers/projects_helper.rb
View file @
150c3637
...
...
@@ -241,7 +241,7 @@ def default_url_to_repo(project = @project)
when
'ssh'
project
.
ssh_url_to_repo
else
project
.
http_url_to_repo
project
.
http_url_to_repo
(
current_user
)
end
end
...
...
app/models/project.rb
View file @
150c3637
...
...
@@ -873,8 +873,14 @@ def ssh_url_to_repo
url_to_repo
end
def
http_url_to_repo
"
#{
web_url
}
.git"
def
http_url_to_repo
(
user
=
nil
)
url
=
web_url
if
user
url
.
sub!
(
%r{
\A
https?://}
)
{
|
protocol
|
"
#{
protocol
}#{
user
.
username
}
@"
}
end
"
#{
url
}
.git"
end
# Check if current branch name is marked as protected in the system
...
...
changelogs/unreleased/1937-https-clone-url-username.yml
0 → 100644
View file @
150c3637
---
title
:
Add the Username to the HTTP(S) clone URL of a Repository
merge_request
:
9347
author
:
Jan Christophersen
features/steps/explore/projects.rb
View file @
150c3637
...
...
@@ -49,7 +49,7 @@ class Spinach::Features::ExploreProjects < Spinach::FeatureSteps
step
'I should see an http link to the repository'
do
project
=
Project
.
find_by
(
name:
'Community'
)
expect
(
page
).
to
have_field
(
'project_clone'
,
with:
project
.
http_url_to_repo
)
expect
(
page
).
to
have_field
(
'project_clone'
,
with:
project
.
http_url_to_repo
(
@user
)
)
end
step
'I should see an ssh link to the repository'
do
...
...
spec/features/admin/admin_disables_git_access_protocol_spec.rb
View file @
150c3637
...
...
@@ -32,7 +32,7 @@
scenario
'shows only HTTP url'
do
visit_project
expect
(
page
).
to
have_content
(
"git clone
#{
project
.
http_url_to_repo
}
"
)
expect
(
page
).
to
have_content
(
"git clone
#{
project
.
http_url_to_repo
(
admin
)
}
"
)
expect
(
page
).
not_to
have_selector
(
'#clone-dropdown'
)
end
end
...
...
spec/features/projects/developer_views_empty_project_instructions_spec.rb
View file @
150c3637
...
...
@@ -56,8 +56,14 @@ def select_protocol(protocol)
end
def
expect_instructions_for
(
protocol
)
msg
=
:"
#{
protocol
.
downcase
}
_url_to_repo"
expect
(
page
).
to
have_content
(
"git clone
#{
project
.
send
(
msg
)
}
"
)
url
=
case
protocol
when
'ssh'
project
.
ssh_url_to_repo
when
'http'
project
.
http_url_to_repo
(
developer
)
end
expect
(
page
).
to
have_content
(
"git clone
#{
url
}
"
)
end
end
spec/models/project_spec.rb
View file @
150c3637
...
...
@@ -1896,4 +1896,25 @@ def enable_lfs
end
end
end
describe
'#http_url_to_repo'
do
let
(
:project
)
{
create
:empty_project
}
context
'when no user is given'
do
it
'returns the url to the repo without a username'
do
url
=
project
.
http_url_to_repo
expect
(
url
).
to
eq
(
project
.
http_url_to_repo
)
expect
(
url
).
not_to
include
(
'@'
)
end
end
context
'when user is given'
do
it
'returns the url to the repo with the username'
do
user
=
build_stubbed
(
:user
)
expect
(
project
.
http_url_to_repo
(
user
)).
to
match
(
%r{https?:
\/\/
#{
user
.
username
}
@}
)
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