Commit 3606a1488952008426b1be870e62804b22fe8a61
1 parent
e25ddca0
Exists in
master
and in
4 other branches
ExtractsPath: Use ref_names instead of branches+tags
Showing
2 changed files
with
6 additions
and
7 deletions
Show diff stats
lib/extracts_path.rb
... | ... | @@ -57,16 +57,16 @@ module ExtractsPath |
57 | 57 | # Append a trailing slash if we only get a ref and no file path |
58 | 58 | id = input |
59 | 59 | id += '/' unless id.ends_with?('/') |
60 | - | |
61 | - valid_refs = @project.branches + @project.tags | |
62 | - valid_refs.select! { |v| id.start_with?("#{v.name}/") } | |
63 | - | |
60 | + | |
61 | + valid_refs = @project.ref_names | |
62 | + valid_refs.select! { |v| id.start_with?("#{v}/") } | |
63 | + | |
64 | 64 | if valid_refs.length != 1 |
65 | 65 | # No exact ref match, so just try our best |
66 | 66 | pair = id.match(/([^\/]+)(.*)/).captures |
67 | 67 | else |
68 | 68 | # Partition the string into the ref and the path, ignoring the empty first value |
69 | - pair = id.partition(valid_refs.first.name)[1..-1] | |
69 | + pair = id.partition(valid_refs.first)[1..-1] | |
70 | 70 | end |
71 | 71 | end |
72 | 72 | ... | ... |
spec/lib/extracts_path_spec.rb
... | ... | @@ -7,8 +7,7 @@ describe ExtractsPath do |
7 | 7 | |
8 | 8 | before do |
9 | 9 | @project = project |
10 | - project.stub(:branches).and_return([stub(name: 'master'), stub(name: 'foo/bar/baz')]) | |
11 | - project.stub(:tags).and_return([stub(name: 'master'), stub(name: 'master')]) | |
10 | + project.stub(:ref_names).and_return(['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0']) | |
12 | 11 | end |
13 | 12 | |
14 | 13 | describe '#extract_ref' do | ... | ... |