summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 085f4e6398f..2c244fc0410 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -62,6 +62,19 @@ class Commit
(self.class === other) && (raw == other.raw)
end
+ def self.reference_prefix
+ '@'
+ end
+
+ # Pattern used to extract commit references from text
+ #
+ # The SHA can be between 6 and 40 hex characters.
+ #
+ # This pattern supports cross-project references.
+ def self.reference_pattern
+ %r{(?:#{Project.reference_pattern}#{reference_prefix})?(?<commit>\h{6,40})}
+ end
+
def to_reference(from_project = nil)
if cross_project_reference?(from_project)
"#{project.to_reference}@#{id}"