ExtractsPath: Use ref_names instead of branches+tags
This commit is contained in:
parent
e25ddca0c4
commit
3606a14889
|
@ -58,15 +58,15 @@ module ExtractsPath
|
||||||
id = input
|
id = input
|
||||||
id += '/' unless id.ends_with?('/')
|
id += '/' unless id.ends_with?('/')
|
||||||
|
|
||||||
valid_refs = @project.branches + @project.tags
|
valid_refs = @project.ref_names
|
||||||
valid_refs.select! { |v| id.start_with?("#{v.name}/") }
|
valid_refs.select! { |v| id.start_with?("#{v}/") }
|
||||||
|
|
||||||
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.name)[1..-1]
|
pair = id.partition(valid_refs.first)[1..-1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,7 @@ describe ExtractsPath do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@project = project
|
@project = project
|
||||||
project.stub(:branches).and_return([stub(name: 'master'), stub(name: 'foo/bar/baz')])
|
project.stub(:ref_names).and_return(['master', 'foo/bar/baz', '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
|
||||||
|
|
Loading…
Reference in a new issue