diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-08-10 11:37:45 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-08-10 11:37:45 +0000 |
commit | e5c0f495a4384157535fe768f04e984a85fd4d79 (patch) | |
tree | c8dbd5af0456138aa3e8f19b22762e5187855dd6 /app | |
parent | c8b0a17ff7aab2193092cb32d3203319c14dfea9 (diff) | |
parent | 34e912b538b54619920b714b5177798597758808 (diff) | |
download | gitlab-ce-e5c0f495a4384157535fe768f04e984a85fd4d79.tar.gz |
Merge branch '28930-add-project-reference-filter' into 'master'
Resolve "GFM : provide 'project' reference in comment"
Closes #28930
See merge request gitlab-org/gitlab-ce!20285
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 36089995ed3..7735f23cb9e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -470,6 +470,24 @@ class Project < ActiveRecord::Base }x end + def reference_postfix + '>' + end + + def reference_postfix_escaped + '>' + end + + # Pattern used to extract `namespace/project>` project references from text. + # '>' or its escaped form ('>') are checked for because '>' is sometimes escaped + # when the reference comes from an external source. + def markdown_reference_pattern + %r{ + #{reference_pattern} + (#{reference_postfix}|#{reference_postfix_escaped}) + }x + end + def trending joins('INNER JOIN trending_projects ON projects.id = trending_projects.project_id') .reorder('trending_projects.id ASC') @@ -908,6 +926,10 @@ class Project < ActiveRecord::Base end end + def to_reference_with_postfix + "#{to_reference(full: true)}#{self.class.reference_postfix}" + end + # `from` argument can be a Namespace or Project. def to_reference(from = nil, full: false) if full || cross_namespace_reference?(from) |