Commit fe8c9021266c579127cf52f6456eb0090e400e63
1 parent
1c7aecc8
Exists in
spb-stable
and in
3 other branches
Add support for relative submodules
Showing
2 changed files
with
18 additions
and
0 deletions
Show diff stats
CHANGELOG
@@ -3,6 +3,7 @@ v 6.7.0 | @@ -3,6 +3,7 @@ v 6.7.0 | ||
3 | - Add edit file button to MergeRequest diff | 3 | - Add edit file button to MergeRequest diff |
4 | - Public groups (Jason Hollingsworth) | 4 | - Public groups (Jason Hollingsworth) |
5 | - Cleaner headers in Notification Emails (Pierre de La Morinerie) | 5 | - Cleaner headers in Notification Emails (Pierre de La Morinerie) |
6 | + - Add support for relative submodules | ||
6 | 7 | ||
7 | v 6.6.2 | 8 | v 6.6.2 |
8 | - Fix 500 error on branch/tag create or remove via UI | 9 | - Fix 500 error on branch/tag create or remove via UI |
@@ -12,6 +12,8 @@ module SubmoduleHelper | @@ -12,6 +12,8 @@ module SubmoduleHelper | ||
12 | 12 | ||
13 | if self_url?(url, project) | 13 | if self_url?(url, project) |
14 | return project_path(project), project_tree_path(project, submodule_item.id) | 14 | return project_path(project), project_tree_path(project, submodule_item.id) |
15 | + elsif relative_self_url?(url) | ||
16 | + relative_self_links(url, submodule_item.id) | ||
15 | elsif github_dot_com_url?(url) | 17 | elsif github_dot_com_url?(url) |
16 | standard_links('github.com', project, submodule_item.id) | 18 | standard_links('github.com', project, submodule_item.id) |
17 | elsif gitlab_dot_com_url?(url) | 19 | elsif gitlab_dot_com_url?(url) |
@@ -36,8 +38,23 @@ module SubmoduleHelper | @@ -36,8 +38,23 @@ module SubmoduleHelper | ||
36 | url == gitlab_shell.url_to_repo(project) | 38 | url == gitlab_shell.url_to_repo(project) |
37 | end | 39 | end |
38 | 40 | ||
41 | + def relative_self_url?(url) | ||
42 | + # (./)? ( (../repo.git) | (../../project/repo.git) ) | ||
43 | + url =~ /(^((\.\/)?(((\.\.)\/)|((\.\.)\/(\.\.)\/.*\/)))[^\.\/]*\.git)\Z/ | ||
44 | + end | ||
45 | + | ||
39 | def standard_links(host, project, commit) | 46 | def standard_links(host, project, commit) |
40 | base = [ 'https://', host, '/', project ].join('') | 47 | base = [ 'https://', host, '/', project ].join('') |
41 | return base, [ base, '/tree/', commit ].join('') | 48 | return base, [ base, '/tree/', commit ].join('') |
42 | end | 49 | end |
50 | + | ||
51 | + def relative_self_links(url, commit) | ||
52 | + if url.scan(/(\.\.)/).size == 2 | ||
53 | + base = [ Gitlab.config.gitlab.url, '/', url[/.*\/(.*)\/.*\.git/, 1] ].join('') | ||
54 | + else | ||
55 | + base = [ Gitlab.config.gitlab.url, '/', @project.group.path ].join('') | ||
56 | + end | ||
57 | + base = [ base, '/', url[/.*\/(.*)\.git/, 1] ].join('') | ||
58 | + return base, [ base, '/tree/', commit ].join('') | ||
59 | + end | ||
43 | end | 60 | end |