Fix bug with branches whose name contains slash

This commit is contained in:
Valeriy Sizov 2012-10-04 19:31:31 +03:00
parent 73d5e51a2d
commit e25ddca0c4
2 changed files with 9 additions and 9 deletions

View file

@ -56,22 +56,22 @@ module ExtractsPath
# Append a trailing slash if we only get a ref and no file path
id = input
id += '/' unless id.include?('/')
id += '/' unless id.ends_with?('/')
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
# 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)[1..-1]
pair = id.partition(valid_refs.first.name)[1..-1]
end
end
# Remove leading slash from path
pair[1].gsub!(/^\//, '')
# Remove ending slashes from path
pair[1].gsub!(/^\/|\/$/, '')
pair
end