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
f0377407
Commit
f0377407
authored
Oct 10, 2019
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow custom HTTP Git clone URL root
It replaces everything before the repo-specific path.
parent
2584a397
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
151 additions
and
19 deletions
+151
-19
app/helpers/application_settings_helper.rb
app/helpers/application_settings_helper.rb
+2
-1
app/models/application_setting_implementation.rb
app/models/application_setting_implementation.rb
+2
-1
app/models/project.rb
app/models/project.rb
+14
-3
app/models/project_wiki.rb
app/models/project_wiki.rb
+4
-1
db/migrate/20191009222222_add_custom_http_clone_url_root_to_application_settings.rb
...add_custom_http_clone_url_root_to_application_settings.rb
+13
-0
db/schema.rb
db/schema.rb
+1
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+97
-9
spec/models/project_wiki_spec.rb
spec/models/project_wiki_spec.rb
+18
-4
No files found.
app/helpers/application_settings_helper.rb
View file @
f0377407
...
...
@@ -291,7 +291,8 @@ module ApplicationSettingsHelper
:snowplow_enabled
,
:snowplow_site_id
,
:push_event_hooks_limit
,
:push_event_activities_limit
:push_event_activities_limit
,
:custom_http_clone_url_root
]
end
...
...
app/models/application_setting_implementation.rb
View file @
f0377407
...
...
@@ -128,7 +128,8 @@ module ApplicationSettingImplementation
snowplow_collector_hostname:
nil
,
snowplow_cookie_domain:
nil
,
snowplow_enabled:
false
,
snowplow_site_id:
nil
snowplow_site_id:
nil
,
custom_http_clone_url_root:
nil
}
end
...
...
app/models/project.rb
View file @
f0377407
...
...
@@ -1036,8 +1036,8 @@ class Project < ApplicationRecord
end
end
def
web_url
Gitlab
::
Routing
.
url_helpers
.
project_url
(
self
)
def
web_url
(
only_path:
nil
)
Gitlab
::
Routing
.
url_helpers
.
project_url
(
self
,
only_path:
only_path
)
end
def
readme_url
...
...
@@ -1316,7 +1316,18 @@ class Project < ApplicationRecord
end
def
http_url_to_repo
"
#{
web_url
}
.git"
custom_root
=
Gitlab
::
CurrentSettings
.
custom_http_clone_url_root
project_url
=
if
custom_root
.
present?
Gitlab
::
Utils
.
append_path
(
custom_root
,
web_url
(
only_path:
true
)
)
else
web_url
end
"
#{
project_url
}
.git"
end
# Is overridden in EE
...
...
app/models/project_wiki.rb
View file @
f0377407
...
...
@@ -54,7 +54,10 @@ class ProjectWiki
end
def
http_url_to_repo
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
full_path
}
.git"
root_url
=
Gitlab
::
CurrentSettings
.
custom_http_clone_url_root
.
presence
||
Gitlab
.
config
.
gitlab
.
url
"
#{
root_url
}
/
#{
full_path
}
.git"
end
def
wiki_base_path
...
...
db/migrate/20191009222222_add_custom_http_clone_url_root_to_application_settings.rb
0 → 100644
View file @
f0377407
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddCustomHttpCloneUrlRootToApplicationSettings
<
ActiveRecord
::
Migration
[
5.2
]
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
def
change
add_column
:application_settings
,
:custom_http_clone_url_root
,
:string
,
limit:
511
end
end
db/schema.rb
View file @
f0377407
...
...
@@ -340,6 +340,7 @@ ActiveRecord::Schema.define(version: 2019_10_16_220135) do
t
.
integer
"throttle_incident_management_notification_per_period"
,
default:
3600
t
.
integer
"push_event_hooks_limit"
,
default:
3
,
null:
false
t
.
integer
"push_event_activities_limit"
,
default:
3
,
null:
false
t
.
string
"custom_http_clone_url_root"
,
limit:
511
t
.
index
[
"custom_project_templates_group_id"
],
name:
"index_application_settings_on_custom_project_templates_group_id"
t
.
index
[
"file_template_project_id"
],
name:
"index_application_settings_on_file_template_project_id"
t
.
index
[
"instance_administration_project_id"
],
name:
"index_applicationsettings_on_instance_administration_project_id"
...
...
spec/models/project_spec.rb
View file @
f0377407
...
...
@@ -631,8 +631,38 @@ describe Project do
describe
"#web_url"
do
let
(
:project
)
{
create
(
:project
,
path:
"somewhere"
)
}
it
'returns the full web URL for this repo'
do
expect
(
project
.
web_url
).
to
eq
(
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
project
.
namespace
.
full_path
}
/somewhere"
)
context
'when given the only_path option'
do
subject
{
project
.
web_url
(
only_path:
only_path
)
}
context
'when only_path is false'
do
let
(
:only_path
)
{
false
}
it
'returns the full web URL for this repo'
do
expect
(
subject
).
to
eq
(
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
project
.
namespace
.
full_path
}
/somewhere"
)
end
end
context
'when only_path is true'
do
let
(
:only_path
)
{
true
}
it
'returns the relative web URL for this repo'
do
expect
(
subject
).
to
eq
(
"/
#{
project
.
namespace
.
full_path
}
/somewhere"
)
end
end
context
'when only_path is nil'
do
let
(
:only_path
)
{
nil
}
it
'returns the full web URL for this repo'
do
expect
(
subject
).
to
eq
(
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
project
.
namespace
.
full_path
}
/somewhere"
)
end
end
end
context
'when not given the only_path option'
do
it
'returns the full web URL for this repo'
do
expect
(
project
.
web_url
).
to
eq
(
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
project
.
namespace
.
full_path
}
/somewhere"
)
end
end
end
...
...
@@ -3226,20 +3256,78 @@ describe Project do
describe
'#http_url_to_repo'
do
let
(
:project
)
{
create
(
:project
)
}
it
'returns the url to the repo without a username'
do
expect
(
project
.
http_url_to_repo
).
to
eq
(
"
#{
project
.
web_url
}
.git"
)
expect
(
project
.
http_url_to_repo
).
not_to
include
(
'@'
)
context
'when a custom HTTP clone URL root is not set'
do
it
'returns the url to the repo without a username'
do
expect
(
project
.
http_url_to_repo
).
to
eq
(
"
#{
project
.
web_url
}
.git"
)
expect
(
project
.
http_url_to_repo
).
not_to
include
(
'@'
)
end
end
context
'when a custom HTTP clone URL root is set'
do
before
do
stub_application_setting
(
custom_http_clone_url_root:
custom_http_clone_url_root
)
end
context
'when custom HTTP clone URL root has a relative URL root'
do
context
'when custom HTTP clone URL root ends with a slash'
do
let
(
:custom_http_clone_url_root
)
{
'https://git.example.com:51234/mygitlab/'
}
it
'returns the url to the repo, with the root replaced with the custom one'
do
expect
(
project
.
http_url_to_repo
).
to
eq
(
"https://git.example.com:51234/mygitlab/
#{
project
.
full_path
}
.git"
)
end
end
context
'when custom HTTP clone URL root does not end with a slash'
do
let
(
:custom_http_clone_url_root
)
{
'https://git.example.com:51234/mygitlab'
}
it
'returns the url to the repo, with the root replaced with the custom one'
do
expect
(
project
.
http_url_to_repo
).
to
eq
(
"https://git.example.com:51234/mygitlab/
#{
project
.
full_path
}
.git"
)
end
end
end
context
'when custom HTTP clone URL root does not have a relative URL root'
do
context
'when custom HTTP clone URL root ends with a slash'
do
let
(
:custom_http_clone_url_root
)
{
'https://git.example.com:51234/'
}
it
'returns the url to the repo, with the root replaced with the custom one'
do
expect
(
project
.
http_url_to_repo
).
to
eq
(
"https://git.example.com:51234/
#{
project
.
full_path
}
.git"
)
end
end
context
'when custom HTTP clone URL root does not end with a slash'
do
let
(
:custom_http_clone_url_root
)
{
'https://git.example.com:51234'
}
it
'returns the url to the repo, with the root replaced with the custom one'
do
expect
(
project
.
http_url_to_repo
).
to
eq
(
"https://git.example.com:51234/
#{
project
.
full_path
}
.git"
)
end
end
end
end
end
describe
'#lfs_http_url_to_repo'
do
let
(
:project
)
{
create
(
:project
)
}
it
'returns the url to the repo without a username'
do
lfs_http_url_to_repo
=
project
.
lfs_http_url_to_repo
(
'operation_that_doesnt_matter'
)
context
'when a custom HTTP clone URL root is not set'
do
it
'returns the url to the repo without a username'
do
lfs_http_url_to_repo
=
project
.
lfs_http_url_to_repo
(
'operation_that_doesnt_matter'
)
expect
(
lfs_http_url_to_repo
).
to
eq
(
"
#{
project
.
web_url
}
.git"
)
expect
(
lfs_http_url_to_repo
).
not_to
include
(
'@'
)
end
end
expect
(
lfs_http_url_to_repo
).
to
eq
(
"
#{
project
.
web_url
}
.git"
)
expect
(
lfs_http_url_to_repo
).
not_to
include
(
'@'
)
context
'when a custom HTTP clone URL root is set'
do
before
do
stub_application_setting
(
custom_http_clone_url_root:
'https://git.example.com:51234'
)
end
it
'returns the url to the repo, with the root replaced with the custom one'
do
lfs_http_url_to_repo
=
project
.
lfs_http_url_to_repo
(
'operation_that_doesnt_matter'
)
expect
(
lfs_http_url_to_repo
).
to
eq
(
"https://git.example.com:51234/
#{
project
.
full_path
}
.git"
)
end
end
end
...
...
spec/models/project_wiki_spec.rb
View file @
f0377407
...
...
@@ -47,11 +47,25 @@ describe ProjectWiki do
describe
"#http_url_to_repo"
do
let
(
:project
)
{
create
:project
}
it
'returns the full http url to the repo'
do
expected_url
=
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
subject
.
full_path
}
.git"
context
'when a custom HTTP clone URL root is not set'
do
it
'returns the full http url to the repo'
do
expected_url
=
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
subject
.
full_path
}
.git"
expect
(
project_wiki
.
http_url_to_repo
).
to
eq
(
expected_url
)
expect
(
project_wiki
.
http_url_to_repo
).
not_to
include
(
'@'
)
expect
(
project_wiki
.
http_url_to_repo
).
to
eq
(
expected_url
)
expect
(
project_wiki
.
http_url_to_repo
).
not_to
include
(
'@'
)
end
end
context
'when a custom HTTP clone URL root is set'
do
before
do
stub_application_setting
(
custom_http_clone_url_root:
'https://git.example.com:51234'
)
end
it
'returns the full http url to the repo, with the root replaced with the custom one'
do
expected_url
=
"https://git.example.com:51234/
#{
subject
.
full_path
}
.git"
expect
(
project_wiki
.
http_url_to_repo
).
to
eq
(
expected_url
)
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