Commit 3606a148 authored by Robert Speicher's avatar Robert Speicher
Browse files

ExtractsPath: Use ref_names instead of branches+tags

parent e25ddca0
......@@ -57,16 +57,16 @@ def extract_ref(input)
# 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.tags! { |v| id.start_with?("#{}/") }
valid_refs = @project.ref_names! { |v| id.start_with?("#{v}/") }
if valid_refs.length != 1
# No exact ref match, so just try our best
pair = id.match(/([^\/]+)(.*)/).captures
# Partition the string into the ref and the path, ignoring the empty first value
pair = id.partition([1..-1]
pair = id.partition(valid_refs.first)[1..-1]
......@@ -7,8 +7,7 @@
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'])
describe '#extract_ref' do
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment