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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
7d089701
Commit
7d089701
authored
Apr 09, 2015
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken file browsing with a submodule that has a relative link
Closes #775
parent
f3f85602
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
6 deletions
+49
-6
CHANGELOG
CHANGELOG
+1
-0
app/helpers/submodule_helper.rb
app/helpers/submodule_helper.rb
+13
-6
spec/helpers/submodule_helper_spec.rb
spec/helpers/submodule_helper_spec.rb
+35
-0
No files found.
CHANGELOG
View file @
7d089701
Please view this file on the master branch, on stable branches it's out of date.
Please view this file on the master branch, on stable branches it's out of date.
v 7.10.0 (unreleased)
v 7.10.0 (unreleased)
- Fix broken file browsing with a submodule that contains a relative link (Stan Hu)
- Fix bug where Wiki pages that included a '/' were no longer accessible (Stan Hu)
- Fix bug where Wiki pages that included a '/' were no longer accessible (Stan Hu)
- Fix bug where error messages from Dropzone would not be displayed on the issues page (Stan Hu)
- Fix bug where error messages from Dropzone would not be displayed on the issues page (Stan Hu)
- Add ability to configure Reply-To address in gitlab.yml (Stan Hu)
- Add ability to configure Reply-To address in gitlab.yml (Stan Hu)
...
...
app/helpers/submodule_helper.rb
View file @
7d089701
...
@@ -53,15 +53,22 @@ module SubmoduleHelper
...
@@ -53,15 +53,22 @@ module SubmoduleHelper
end
end
def
relative_self_links
(
url
,
commit
)
def
relative_self_links
(
url
,
commit
)
if
url
.
scan
(
/(\.\.\/)/
).
size
==
2
# Map relative links to a namespace and project
base
=
url
[
/([^\/]*\/[^\/]*)\.git/
,
1
]
# For example:
else
# ../bar.git -> same namespace, repo bar
base
=
[
@project
.
group
.
path
,
'/'
,
url
[
/([^\/]*)\.git/
,
1
]
].
join
(
''
)
# ../foo/bar.git -> namespace foo, repo bar
# ../../foo/bar/baz.git -> namespace bar, repo baz
components
=
url
.
split
(
'/'
)
base
=
components
.
pop
.
gsub
(
/.git$/
,
''
)
namespace
=
components
.
pop
.
gsub
(
/^\.\.$/
,
''
)
if
namespace
.
empty?
namespace
=
@project
.
group
.
path
end
end
[
[
namespace_project_path
(
base
.
namespace
,
base
),
namespace_project_path
(
namespace
,
base
),
namespace_project_tree_path
(
base
.
namespace
,
base
,
commit
)
namespace_project_tree_path
(
namespace
,
base
,
commit
)
]
]
end
end
end
end
spec/helpers/submodule_helper_spec.rb
View file @
7d089701
require
'spec_helper'
require
'spec_helper'
describe
SubmoduleHelper
do
describe
SubmoduleHelper
do
include
RepoHelpers
describe
'submodule links'
do
describe
'submodule links'
do
let
(
:submodule_item
)
{
double
(
id:
'hash'
,
path:
'rack'
)
}
let
(
:submodule_item
)
{
double
(
id:
'hash'
,
path:
'rack'
)
}
let
(
:config
)
{
Gitlab
.
config
.
gitlab
}
let
(
:config
)
{
Gitlab
.
config
.
gitlab
}
...
@@ -111,6 +113,39 @@ describe SubmoduleHelper do
...
@@ -111,6 +113,39 @@ describe SubmoduleHelper do
expect
(
submodule_links
(
submodule_item
)).
to
eq
([
repo
.
submodule_url_for
,
nil
])
expect
(
submodule_links
(
submodule_item
)).
to
eq
([
repo
.
submodule_url_for
,
nil
])
end
end
end
end
context
'submodules with relative links'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
before
do
self
.
instance_variable_set
(
:@project
,
project
)
end
it
'one level down'
do
commit_id
=
sample_commit
[
:id
]
result
=
relative_self_links
(
'../test.git'
,
commit_id
)
expect
(
result
).
to
eq
([
"/
#{
group
.
path
}
/test"
,
"/
#{
group
.
path
}
/test/tree/
#{
commit_id
}
"
])
end
it
'two levels down'
do
commit_id
=
sample_commit
[
:id
]
result
=
relative_self_links
(
'../../test.git'
,
commit_id
)
expect
(
result
).
to
eq
([
"/
#{
group
.
path
}
/test"
,
"/
#{
group
.
path
}
/test/tree/
#{
commit_id
}
"
])
end
it
'one level down with namespace and repo'
do
commit_id
=
sample_commit
[
:id
]
result
=
relative_self_links
(
'../foobar/test.git'
,
commit_id
)
expect
(
result
).
to
eq
([
"/foobar/test"
,
"/foobar/test/tree/
#{
commit_id
}
"
])
end
it
'two levels down with namespace and repo'
do
commit_id
=
sample_commit
[
:id
]
result
=
relative_self_links
(
'../foobar/baz/test.git'
,
commit_id
)
expect
(
result
).
to
eq
([
"/baz/test"
,
"/baz/test/tree/
#{
commit_id
}
"
])
end
end
end
end
def
stub_url
(
url
)
def
stub_url
(
url
)
...
...
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