diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-04-06 18:13:18 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-04-06 18:53:14 +0300 |
commit | 4dd1f906fd60bebd433dc9c4b5879c1e575fb735 (patch) | |
tree | cb175128bac00e0174a336c3d3cb5bf8707e5bea /app/models | |
parent | 166b4575a6353668c894fea0ba234d0b371dee03 (diff) |
Add support for patch link extension for commit links on GFM
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/commit.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 3f7f36e83c0..de860df4b9c 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -30,6 +30,8 @@ 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) pipeline = field == :description ? :commit_description : :single_line @@ -143,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) |