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
Boxiang Sun
gitlab-ce
Commits
d9027df5
Commit
d9027df5
authored
Jan 23, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2706 from jfut/gh-issue-2602
Remove relative_url_root from path. Fixes #2602
parents
aa99660f
79b9249f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
lib/extracts_path.rb
lib/extracts_path.rb
+2
-0
spec/lib/extracts_path_spec.rb
spec/lib/extracts_path_spec.rb
+23
-0
No files found.
lib/extracts_path.rb
View file @
d9027df5
...
...
@@ -50,6 +50,8 @@ module ExtractsPath
return
pair
unless
@project
# Remove relative_url_root from path
input
.
gsub!
(
/^
#{
Gitlab
.
config
.
gitlab
.
relative_url_root
}
/
,
""
)
# Remove project, actions and all other staff from path
input
.
gsub!
(
/^\/
#{
Regexp
.
escape
(
@project
.
path_with_namespace
)
}
/
,
""
)
input
.
gsub!
(
/^\/(tree|commits|blame|blob|refs)\//
,
""
)
# remove actions
...
...
spec/lib/extracts_path_spec.rb
View file @
d9027df5
...
...
@@ -73,5 +73,28 @@ describe ExtractsPath do
extract_ref
(
'/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG?_=12354435'
).
should
==
[
'v2.0.0'
,
'CHANGELOG'
]
end
end
context
"with a fullpath and a relative_url_root"
do
before
do
Gitlab
.
config
.
gitlab
.
stub
(
relative_url_root:
'/relative'
)
end
it
"extracts a valid branch with relative_url_root"
do
extract_ref
(
'/relative/gitlab/gitlab-ci/tree/foo/bar/baz/CHANGELOG'
).
should
==
[
'foo/bar/baz'
,
'CHANGELOG'
]
end
it
"extracts a valid tag"
do
extract_ref
(
'/relative/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG'
).
should
==
[
'v2.0.0'
,
'CHANGELOG'
]
end
it
"extracts a valid commit SHA"
do
extract_ref
(
'/relative/gitlab/gitlab-ci/tree/f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG'
).
should
==
[
'f4b14494ef6abf3d144c28e4af0c20143383e062'
,
'CHANGELOG'
]
end
it
"extracts a timestamp"
do
extract_ref
(
'/relative/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG?_=12354435'
).
should
==
[
'v2.0.0'
,
'CHANGELOG'
]
end
end
end
end
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