Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-05-14 23:59:39 +0300
committerRobert Speicher <rspeicher@gmail.com>2015-05-26 22:48:32 +0300
commitb88da58cb6272a86b6df2e4efe392f10e689a6b2 (patch)
tree1271524cfe6fa5d733cc847c72b96a19810d06aa /app/models/commit_range.rb
parent94af050117df20a661e03055a5002cae90282d6d (diff)
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.