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
e25ddca0
Commit
e25ddca0
authored
Oct 04, 2012
by
Valeriy Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug with branches whose name contains slash
parent
73d5e51a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
lib/extracts_path.rb
lib/extracts_path.rb
+7
-7
spec/lib/extracts_path_spec.rb
spec/lib/extracts_path_spec.rb
+2
-2
No files found.
lib/extracts_path.rb
View file @
e25ddca0
...
@@ -56,22 +56,22 @@ module ExtractsPath
...
@@ -56,22 +56,22 @@ module ExtractsPath
# Append a trailing slash if we only get a ref and no file path
# Append a trailing slash if we only get a ref and no file path
id
=
input
id
=
input
id
+=
'/'
unless
id
.
include
?
(
'/'
)
id
+=
'/'
unless
id
.
ends_with
?
(
'/'
)
valid_refs
=
@project
.
branches
+
@project
.
tags
valid_refs
=
@project
.
branches
+
@project
.
tags
valid_refs
.
select!
{
|
v
|
id
.
start_with?
(
"
#{
v
}
/"
)
}
valid_refs
.
select!
{
|
v
|
id
.
start_with?
(
"
#{
v
.
name
}
/"
)
}
if
valid_refs
.
length
!=
1
if
valid_refs
.
length
!=
1
# No exact ref match, so just try our best
# No exact ref match, so just try our best
pair
=
id
.
match
(
/([^\/]+)(.*)/
).
captures
pair
=
id
.
match
(
/([^\/]+)(.*)/
).
captures
else
else
# Partition the string into the ref and the path, ignoring the empty first value
# Partition the string into the ref and the path, ignoring the empty first value
pair
=
id
.
partition
(
valid_refs
.
first
)[
1
..-
1
]
pair
=
id
.
partition
(
valid_refs
.
first
.
name
)[
1
..-
1
]
end
end
end
end
# Remove
leading slash
from path
# Remove
ending slashes
from path
pair
[
1
].
gsub!
(
/^\//
,
''
)
pair
[
1
].
gsub!
(
/^\/
|\/$
/
,
''
)
pair
pair
end
end
...
...
spec/lib/extracts_path_spec.rb
View file @
e25ddca0
...
@@ -7,8 +7,8 @@ describe ExtractsPath do
...
@@ -7,8 +7,8 @@ describe ExtractsPath do
before
do
before
do
@project
=
project
@project
=
project
project
.
stub
(
:branches
).
and_return
([
'master'
,
'foo/bar/baz'
])
project
.
stub
(
:branches
).
and_return
([
stub
(
name:
'master'
),
stub
(
name:
'foo/bar/baz'
)
])
project
.
stub
(
:tags
).
and_return
([
'v1.0.0'
,
'v2.0.0'
])
project
.
stub
(
:tags
).
and_return
([
stub
(
name:
'master'
),
stub
(
name:
'master'
)
])
end
end
describe
'#extract_ref'
do
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