Surround Project.reference_pattern in parenthesis inside other patterns

This commit is contained in:
Robert Speicher 2015-05-15 16:10:55 -04:00
parent 5cc9b17b8a
commit 1a9da9178c
4 changed files with 7 additions and 4 deletions

View file

@ -72,7 +72,10 @@ class Commit
# #
# This pattern supports cross-project references. # This pattern supports cross-project references.
def self.reference_pattern def self.reference_pattern
%r{(?:#{Project.reference_pattern}#{reference_prefix})?(?<commit>\h{6,40})} %r{
(?:#{Project.reference_pattern}#{reference_prefix})?
(?<commit>\h{6,40})
}x
end end
def to_reference(from_project = nil) def to_reference(from_project = nil)

View file

@ -63,7 +63,7 @@ class Issue < ActiveRecord::Base
# This pattern supports cross-project references. # This pattern supports cross-project references.
def self.reference_pattern def self.reference_pattern
%r{ %r{
#{Project.reference_pattern}? (#{Project.reference_pattern})?
#{Regexp.escape(reference_prefix)}(?<issue>\d+) #{Regexp.escape(reference_prefix)}(?<issue>\d+)
}x }x
end end

View file

@ -145,7 +145,7 @@ class MergeRequest < ActiveRecord::Base
# This pattern supports cross-project references. # This pattern supports cross-project references.
def self.reference_pattern def self.reference_pattern
%r{ %r{
#{Project.reference_pattern}? (#{Project.reference_pattern})?
#{Regexp.escape(reference_prefix)}(?<merge_request>\d+) #{Regexp.escape(reference_prefix)}(?<merge_request>\d+)
}x }x
end end

View file

@ -61,7 +61,7 @@ class Snippet < ActiveRecord::Base
# This pattern supports cross-project references. # This pattern supports cross-project references.
def self.reference_pattern def self.reference_pattern
%r{ %r{
#{Project.reference_pattern}? (#{Project.reference_pattern})?
#{Regexp.escape(reference_prefix)}(?<snippet>\d+) #{Regexp.escape(reference_prefix)}(?<snippet>\d+)
}x }x
end end