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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
3606a148
Commit
3606a148
authored
Oct 04, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ExtractsPath: Use ref_names instead of branches+tags
parent
e25ddca0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
lib/extracts_path.rb
lib/extracts_path.rb
+5
-5
spec/lib/extracts_path_spec.rb
spec/lib/extracts_path_spec.rb
+1
-2
No files found.
lib/extracts_path.rb
View file @
3606a148
...
...
@@ -57,16 +57,16 @@ module ExtractsPath
# Append a trailing slash if we only get a ref and no file path
id
=
input
id
+=
'/'
unless
id
.
ends_with?
(
'/'
)
valid_refs
=
@project
.
branches
+
@project
.
tag
s
valid_refs
.
select!
{
|
v
|
id
.
start_with?
(
"
#{
v
.
name
}
/"
)
}
valid_refs
=
@project
.
ref_name
s
valid_refs
.
select!
{
|
v
|
id
.
start_with?
(
"
#{
v
}
/"
)
}
if
valid_refs
.
length
!=
1
# No exact ref match, so just try our best
pair
=
id
.
match
(
/([^\/]+)(.*)/
).
captures
else
# Partition the string into the ref and the path, ignoring the empty first value
pair
=
id
.
partition
(
valid_refs
.
first
.
name
)[
1
..-
1
]
pair
=
id
.
partition
(
valid_refs
.
first
)[
1
..-
1
]
end
end
...
...
spec/lib/extracts_path_spec.rb
View file @
3606a148
...
...
@@ -7,8 +7,7 @@ describe ExtractsPath do
before
do
@project
=
project
project
.
stub
(
:branches
).
and_return
([
stub
(
name:
'master'
),
stub
(
name:
'foo/bar/baz'
)])
project
.
stub
(
:tags
).
and_return
([
stub
(
name:
'master'
),
stub
(
name:
'master'
)])
project
.
stub
(
:ref_names
).
and_return
([
'master'
,
'foo/bar/baz'
,
'v1.0.0'
,
'v2.0.0'
])
end
describe
'#extract_ref'
do
...
...
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