Merge branch 'fix-relative-submodule-links-with-personal-projects' into 'master'
Fix broken file browsing with relative submodule in personal projects Git submodules with relative links work fine for projects in groups but not in personal projects. This patch fixes this issue. To reproduce the problem, go here: https://gitlab.com/andrewwu.tw/submodule-test/tree/master Closes https://github.com/gitlabhq/gitlabhq/issues/7554 See merge request !565
This commit is contained in:
commit
9f443f4257
3 changed files with 13 additions and 5 deletions
|
@ -8,6 +8,7 @@ v 7.11.0 (unreleased)
|
||||||
- Redirect to sign in page after signing out.
|
- Redirect to sign in page after signing out.
|
||||||
- Fix "Hello @username." references not working by no longer allowing usernames to end in period.
|
- Fix "Hello @username." references not working by no longer allowing usernames to end in period.
|
||||||
-
|
-
|
||||||
|
- Fix broken file browsing with relative submodule in personal projects (Stan Hu)
|
||||||
- Add "Reply quoting selected text" shortcut key (`r`)
|
- Add "Reply quoting selected text" shortcut key (`r`)
|
||||||
- Fix bug causing `@whatever` inside an issue's first code block to be picked up as a user mention.
|
- Fix bug causing `@whatever` inside an issue's first code block to be picked up as a user mention.
|
||||||
- Fix bug causing `@whatever` inside an inline code snippet (backtick-style) to be picked up as a user mention.
|
- Fix bug causing `@whatever` inside an inline code snippet (backtick-style) to be picked up as a user mention.
|
||||||
|
|
|
@ -63,7 +63,7 @@ module SubmoduleHelper
|
||||||
namespace = components.pop.gsub(/^\.\.$/, '')
|
namespace = components.pop.gsub(/^\.\.$/, '')
|
||||||
|
|
||||||
if namespace.empty?
|
if namespace.empty?
|
||||||
namespace = @project.group.path
|
namespace = @project.namespace.name
|
||||||
end
|
end
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
|
@ -117,34 +117,41 @@ describe SubmoduleHelper do
|
||||||
context 'submodules with relative links' do
|
context 'submodules with relative links' do
|
||||||
let(:group) { create(:group) }
|
let(:group) { create(:group) }
|
||||||
let(:project) { create(:project, group: group) }
|
let(:project) { create(:project, group: group) }
|
||||||
|
let(:commit_id) { sample_commit[:id] }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
self.instance_variable_set(:@project, project)
|
self.instance_variable_set(:@project, project)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'one level down' do
|
it 'one level down' do
|
||||||
commit_id = sample_commit[:id]
|
|
||||||
result = relative_self_links('../test.git', commit_id)
|
result = relative_self_links('../test.git', commit_id)
|
||||||
expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"])
|
expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'two levels down' do
|
it 'two levels down' do
|
||||||
commit_id = sample_commit[:id]
|
|
||||||
result = relative_self_links('../../test.git', commit_id)
|
result = relative_self_links('../../test.git', commit_id)
|
||||||
expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"])
|
expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'one level down with namespace and repo' do
|
it 'one level down with namespace and repo' do
|
||||||
commit_id = sample_commit[:id]
|
|
||||||
result = relative_self_links('../foobar/test.git', commit_id)
|
result = relative_self_links('../foobar/test.git', commit_id)
|
||||||
expect(result).to eq(["/foobar/test", "/foobar/test/tree/#{commit_id}"])
|
expect(result).to eq(["/foobar/test", "/foobar/test/tree/#{commit_id}"])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'two levels down with namespace and repo' do
|
it 'two levels down with namespace and repo' do
|
||||||
commit_id = sample_commit[:id]
|
|
||||||
result = relative_self_links('../foobar/baz/test.git', commit_id)
|
result = relative_self_links('../foobar/baz/test.git', commit_id)
|
||||||
expect(result).to eq(["/baz/test", "/baz/test/tree/#{commit_id}"])
|
expect(result).to eq(["/baz/test", "/baz/test/tree/#{commit_id}"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'personal project' do
|
||||||
|
let(:user) { create(:user) }
|
||||||
|
let(:project) { create(:project, namespace: user.namespace) }
|
||||||
|
|
||||||
|
it 'one level down with personal project' do
|
||||||
|
result = relative_self_links('../test.git', commit_id)
|
||||||
|
expect(result).to eq(["/#{user.username}/test", "/#{user.username}/test/tree/#{commit_id}"])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue