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
11423aa2
Commit
11423aa2
authored
Mar 16, 2020
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix submodule links to gist.github.com
parent
067b08dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
0 deletions
+43
-0
app/helpers/submodule_helper.rb
app/helpers/submodule_helper.rb
+11
-0
changelogs/unreleased/26111-fix-github-gist-links.yml
changelogs/unreleased/26111-fix-github-gist-links.yml
+5
-0
spec/helpers/submodule_helper_spec.rb
spec/helpers/submodule_helper_spec.rb
+27
-0
No files found.
app/helpers/submodule_helper.rb
View file @
11423aa2
...
@@ -38,6 +38,8 @@ module SubmoduleHelper
...
@@ -38,6 +38,8 @@ module SubmoduleHelper
url_helpers
.
namespace_project_tree_path
(
namespace
,
project
,
submodule_item_id
)]
url_helpers
.
namespace_project_tree_path
(
namespace
,
project
,
submodule_item_id
)]
elsif
relative_self_url?
(
url
)
elsif
relative_self_url?
(
url
)
relative_self_links
(
url
,
submodule_item_id
,
repository
.
project
)
relative_self_links
(
url
,
submodule_item_id
,
repository
.
project
)
elsif
gist_github_dot_com_url?
(
url
)
gist_github_com_tree_links
(
namespace
,
project
,
submodule_item_id
)
elsif
github_dot_com_url?
(
url
)
elsif
github_dot_com_url?
(
url
)
github_com_tree_links
(
namespace
,
project
,
submodule_item_id
)
github_com_tree_links
(
namespace
,
project
,
submodule_item_id
)
elsif
gitlab_dot_com_url?
(
url
)
elsif
gitlab_dot_com_url?
(
url
)
...
@@ -52,6 +54,10 @@ module SubmoduleHelper
...
@@ -52,6 +54,10 @@ module SubmoduleHelper
protected
protected
def
gist_github_dot_com_url?
(
url
)
url
=~
%r{gist
\.
github
\.
com[/:][^/]+/[^/]+
\Z
}
end
def
github_dot_com_url?
(
url
)
def
github_dot_com_url?
(
url
)
url
=~
%r{github
\.
com[/:][^/]+/[^/]+
\Z
}
url
=~
%r{github
\.
com[/:][^/]+/[^/]+
\Z
}
end
end
...
@@ -78,6 +84,11 @@ module SubmoduleHelper
...
@@ -78,6 +84,11 @@ module SubmoduleHelper
[
base
,
[
base
,
'/-/tree/'
,
commit
].
join
(
''
)]
[
base
,
[
base
,
'/-/tree/'
,
commit
].
join
(
''
)]
end
end
def
gist_github_com_tree_links
(
namespace
,
project
,
commit
)
base
=
[
'https://gist.github.com/'
,
namespace
,
'/'
,
project
].
join
(
''
)
[
base
,
[
base
,
commit
].
join
(
'/'
)]
end
def
github_com_tree_links
(
namespace
,
project
,
commit
)
def
github_com_tree_links
(
namespace
,
project
,
commit
)
base
=
[
'https://github.com/'
,
namespace
,
'/'
,
project
].
join
(
''
)
base
=
[
'https://github.com/'
,
namespace
,
'/'
,
project
].
join
(
''
)
[
base
,
[
base
,
'/tree/'
,
commit
].
join
(
''
)]
[
base
,
[
base
,
'/tree/'
,
commit
].
join
(
''
)]
...
...
changelogs/unreleased/26111-fix-github-gist-links.yml
0 → 100644
View file @
11423aa2
---
title
:
Fix submodule links to gist.github.com
merge_request
:
27346
author
:
type
:
fixed
spec/helpers/submodule_helper_spec.rb
View file @
11423aa2
...
@@ -81,6 +81,33 @@ describe SubmoduleHelper do
...
@@ -81,6 +81,33 @@ describe SubmoduleHelper do
end
end
end
end
context
'submodule on gist.github.com'
do
it
'detects ssh'
do
stub_url
(
'git@gist.github.com:gitlab-org/gitlab-foss.git'
)
is_expected
.
to
eq
([
'https://gist.github.com/gitlab-org/gitlab-foss'
,
'https://gist.github.com/gitlab-org/gitlab-foss/hash'
])
end
it
'detects http'
do
stub_url
(
'http://gist.github.com/gitlab-org/gitlab-foss.git'
)
is_expected
.
to
eq
([
'https://gist.github.com/gitlab-org/gitlab-foss'
,
'https://gist.github.com/gitlab-org/gitlab-foss/hash'
])
end
it
'detects https'
do
stub_url
(
'https://gist.github.com/gitlab-org/gitlab-foss.git'
)
is_expected
.
to
eq
([
'https://gist.github.com/gitlab-org/gitlab-foss'
,
'https://gist.github.com/gitlab-org/gitlab-foss/hash'
])
end
it
'handles urls with no .git on the end'
do
stub_url
(
'http://gist.github.com/gitlab-org/gitlab-foss'
)
is_expected
.
to
eq
([
'https://gist.github.com/gitlab-org/gitlab-foss'
,
'https://gist.github.com/gitlab-org/gitlab-foss/hash'
])
end
it
'returns original with non-standard url'
do
stub_url
(
'http://gist.github.com/another/gitlab-org/gitlab-foss.git'
)
is_expected
.
to
eq
([
repo
.
submodule_url_for
,
nil
])
end
end
context
'submodule on github.com'
do
context
'submodule on github.com'
do
it
'detects ssh'
do
it
'detects ssh'
do
stub_url
(
'git@github.com:gitlab-org/gitlab-foss.git'
)
stub_url
(
'git@github.com:gitlab-org/gitlab-foss.git'
)
...
...
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