summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-05-15 21:23:27 +0000
committerRobert Speicher <robert@gitlab.com>2017-05-15 21:23:27 +0000
commit45c19a9802e7d960283be22a626dfe128e49e03d (patch)
tree43b42e51e64c9f23392745f9cf355e8502842d49
parentcae0803313938e787437f305ebc05a4197c430fa (diff)
parent897a85a461b95ece12a1c5daaa86f55c27ddadcb (diff)
downloadgitlab-ce-45c19a9802e7d960283be22a626dfe128e49e03d.tar.gz
Merge branch 'omega-submodules' into 'master'
Omega submodules See merge request !10797
-rw-r--r--app/helpers/submodule_helper.rb4
-rw-r--r--changelogs/unreleased/omega-submodules.yml4
-rw-r--r--spec/helpers/submodule_helper_spec.rb13
3 files changed, 21 insertions, 0 deletions
diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb
index b739554a7a4..09b73eee8cf 100644
--- a/app/helpers/submodule_helper.rb
+++ b/app/helpers/submodule_helper.rb
@@ -7,6 +7,10 @@ module SubmoduleHelper
def submodule_links(submodule_item, ref = nil, repository = @repository)
url = repository.submodule_url_for(ref, submodule_item.path)
+ if url == '.' || url == './'
+ url = File.join(Gitlab.config.gitlab.url, @project.full_path)
+ end
+
if url =~ /([^\/:]+)\/([^\/]+(?:\.git)?)\Z/
namespace, project = $1, $2
project.sub!(/\.git\z/, '')
diff --git a/changelogs/unreleased/omega-submodules.yml b/changelogs/unreleased/omega-submodules.yml
new file mode 100644
index 00000000000..1488eb72174
--- /dev/null
+++ b/changelogs/unreleased/omega-submodules.yml
@@ -0,0 +1,4 @@
+---
+title: 'Repository browser: handle in-repository submodule urls'
+merge_request:
+author: David Turner
diff --git a/spec/helpers/submodule_helper_spec.rb b/spec/helpers/submodule_helper_spec.rb
index 9da33792659..18935be95c9 100644
--- a/spec/helpers/submodule_helper_spec.rb
+++ b/spec/helpers/submodule_helper_spec.rb
@@ -81,6 +81,19 @@ describe SubmoduleHelper do
end
end
+ context 'in-repository submodule' do
+ let(:group) { create(:group, name: "Master Project", path: "master-project") }
+ let(:project) { create(:empty_project, group: group) }
+ before do
+ self.instance_variable_set(:@project, project)
+ end
+
+ it 'in-repository' do
+ stub_url('./')
+ expect(submodule_links(submodule_item)).to eq(["/master-project/#{project.path}", "/master-project/#{project.path}/tree/hash"])
+ end
+ end
+
context 'submodule on gitlab.com' do
it 'detects ssh' do
stub_url('git@gitlab.com:gitlab-org/gitlab-ce.git')