Commit ea96e0e3 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'fix-repository-has-ambiguous-refs' into 'master'

Fix Repository#has_ambiguous_refs? regex

See merge request gitlab-org/gitlab!39861
parents fbe8a822 84b022a5
......@@ -214,7 +214,7 @@ class Repository
return false if with_slash.empty?
prefixes = no_slash.map { |ref| Regexp.escape(ref) }.join('|')
prefix_regex = %r{^#{prefixes}/}
prefix_regex = %r{^(#{prefixes})/}
with_slash.any? do |ref|
prefix_regex.match?(ref)
......
......@@ -1263,6 +1263,7 @@ RSpec.describe Repository do
%w(a b c/z) | %w(c d) | true
%w(a/b/z) | %w(a/b) | false # we only consider refs ambiguous before the first slash
%w(a/b/z) | %w(a/b a) | true
%w(ab) | %w(abc/d a b) | false
end
with_them 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