diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-05-14 16:59:39 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-05-26 15:48:32 -0400 |
commit | b88da58cb6272a86b6df2e4efe392f10e689a6b2 (patch) | |
tree | 1271524cfe6fa5d733cc847c72b96a19810d06aa /app/models/snippet.rb | |
parent | 94af050117df20a661e03055a5002cae90282d6d (diff) | |
download | gitlab-ce-b88da58cb6272a86b6df2e4efe392f10e689a6b2.tar.gz |
Add `reference_pattern` to Referable models
Diffstat (limited to 'app/models/snippet.rb')
-rw-r--r-- | app/models/snippet.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 8c3167833aa..d1619071f49 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -56,6 +56,16 @@ class Snippet < ActiveRecord::Base '$' end + # Pattern used to extract `$123` snippet references from text + # + # This pattern supports cross-project references. + def self.reference_pattern + %r{ + #{Project.reference_pattern}? + #{Regexp.escape(reference_prefix)}(?<snippet>\d+) + }x + end + def to_reference(from_project = nil) reference = "#{self.class.reference_prefix}#{id}" |