summaryrefslogtreecommitdiff
path: root/app/models/commit_range.rb
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-05-14 16:59:39 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-05-26 15:48:32 -0400
commitb88da58cb6272a86b6df2e4efe392f10e689a6b2 (patch)
tree1271524cfe6fa5d733cc847c72b96a19810d06aa /app/models/commit_range.rb
parent94af050117df20a661e03055a5002cae90282d6d (diff)
downloadgitlab-ce-b88da58cb6272a86b6df2e4efe392f10e689a6b2.tar.gz
Add `reference_pattern` to Referable models
Diffstat (limited to 'app/models/commit_range.rb')
-rw-r--r--app/models/commit_range.rb18
1 files changed, 16 insertions, 2 deletions
diff --git a/app/models/commit_range.rb b/app/models/commit_range.rb
index fb1f6d09be6..86fc9eb01a3 100644
--- a/app/models/commit_range.rb
+++ b/app/models/commit_range.rb
@@ -29,10 +29,24 @@ class CommitRange
# See `exclude_start?`
attr_reader :exclude_start
- # The beginning and ending SHA sums can be between 6 and 40 hex characters,
- # and the range selection can be double- or triple-dot.
+ # The beginning and ending SHAs can be between 6 and 40 hex characters, and
+ # the range notation can be double- or triple-dot.
PATTERN = /\h{6,40}\.{2,3}\h{6,40}/
+ def self.reference_prefix
+ '@'
+ end
+
+ # Pattern used to extract commit range references from text
+ #
+ # This pattern supports cross-project references.
+ def self.reference_pattern
+ %r{
+ (?:#{Project.reference_pattern}#{reference_prefix})?
+ (?<commit_range>#{PATTERN})
+ }x
+ end
+
# Initialize a CommitRange
#
# range_string - The String commit range.