diff options
author | Sean McGivern <sean@gitlab.com> | 2018-04-10 13:56:17 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-04-10 13:56:17 +0100 |
commit | c5a4b4ec7b4dfeeeb99dc105ea61d094d779efdf (patch) | |
tree | e1ef0535f76ea0ca17ee95cba2e35d7d7c58e502 /app/models/commit.rb | |
parent | 2fd7be8c0303afe4394f829ef4db0555dd1c3afa (diff) | |
parent | 89c3c4ccec639f23fd7b2c7f64e5b60b1b5708c8 (diff) | |
download | gitlab-ce-c5a4b4ec7b4dfeeeb99dc105ea61d094d779efdf.tar.gz |
Merge branch 'master' into satishperala/gitlab-ce-20720_webhooks_full_image_urlsatishperala/gitlab-ce-20720_webhooks_full_image_url
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r-- | app/models/commit.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index b64462fb768..de860df4b9c 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -30,9 +30,12 @@ class Commit MIN_SHA_LENGTH = Gitlab::Git::Commit::MIN_SHA_LENGTH COMMIT_SHA_PATTERN = /\h{#{MIN_SHA_LENGTH},40}/.freeze + # Used by GFM to match and present link extensions on node texts and hrefs. + LINK_EXTENSION_PATTERN = /(patch)/.freeze def banzai_render_context(field) - context = { pipeline: :single_line, project: self.project } + pipeline = field == :description ? :commit_description : :single_line + context = { pipeline: pipeline, project: self.project } context[:author] = self.author if self.author context @@ -142,7 +145,8 @@ class Commit end def self.link_reference_pattern - @link_reference_pattern ||= super("commit", /(?<commit>#{COMMIT_SHA_PATTERN})/) + @link_reference_pattern ||= + super("commit", /(?<commit>#{COMMIT_SHA_PATTERN})?(\.(?<extension>#{LINK_EXTENSION_PATTERN}))?/) end def to_reference(from = nil, full: false) |