diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-04-06 20:14:47 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-04-06 20:14:47 +0300 |
commit | f3fa98e93a0017af182ca18b7138a5f530432842 (patch) | |
tree | eb112a58840cc02d40cbecfb4dcd0de386cd7c34 /app/models | |
parent | 9e8f3058af2bd5a80dbff7f84d8c192895cee7d0 (diff) | |
parent | 4dd1f906fd60bebd433dc9c4b5879c1e575fb735 (diff) |
Merge branch '17939-osw-patch-support-gfm' into 'master'
Add support for patch link extension for commit links on GFM
Closes #17939
See merge request gitlab-org/gitlab-ce!18229
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) |