Commit 897a85a4 authored by David Turner's avatar David Turner

submodule_links: Handle in-repository submodule urls

Sometimes it is useful to store submodules in the same repository which
contains links to them.  Make the UI support this.

See
https://github.com/twosigma/git-meta/wiki/The-Omega-Repo
for information about this strategy
Signed-off-by: 's avatarDavid Turner <novalis@novalis.org>
parent ea5d43a3
......@@ -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/, '')
......
---
title: 'Repository browser: handle in-repository submodule urls'
merge_request:
author: David Turner
......@@ -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')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment