Commit acc6e3a0 authored by Robert Speicher's avatar Robert Speicher

Merge branch '44994-osw-use-monospaced-font-on-diffs-commit-ref' into 'master'

Resolve "Render SHA in merge request commit reference with mono spaced font"

Closes #44994

See merge request gitlab-org/gitlab-ce!20228
parents d4a4f1ed ad7fcc7b
---
title: Use monospaced font for MR diff commit link ref on GFM
merge_request:
author:
type: other
...@@ -25,7 +25,10 @@ module Banzai ...@@ -25,7 +25,10 @@ module Banzai
extras = super extras = super
if commit_ref = object_link_commit_ref(object, matches) if commit_ref = object_link_commit_ref(object, matches)
return extras.unshift(commit_ref) klass = reference_class(:commit, tooltip: false)
commit_ref_tag = %(<span class="#{klass}">#{commit_ref}</span>)
return extras.unshift(commit_ref_tag)
end end
path = matches[:path] if matches.names.include?("path") path = matches[:path] if matches.names.include?("path")
......
...@@ -65,8 +65,12 @@ module Banzai ...@@ -65,8 +65,12 @@ module Banzai
context[:skip_project_check] context[:skip_project_check]
end end
def reference_class(type) def reference_class(type, tooltip: true)
"gfm gfm-#{type} has-tooltip" gfm_klass = "gfm gfm-#{type}"
return gfm_klass unless tooltip
"#{gfm_klass} has-tooltip"
end end
# Ensure that a :project key exists in context # Ensure that a :project key exists in context
......
...@@ -210,6 +210,13 @@ describe Banzai::Filter::MergeRequestReferenceFilter do ...@@ -210,6 +210,13 @@ describe Banzai::Filter::MergeRequestReferenceFilter do
.to eq reference .to eq reference
end end
it 'commit ref tag is valid' do
doc = reference_filter("See #{reference}")
commit_ref_tag = doc.css('a').first.css('span.gfm.gfm-commit')
expect(commit_ref_tag.text).to eq(commit.short_id)
end
it 'has valid text' do it 'has valid text' do
doc = reference_filter("See #{reference}") doc = reference_filter("See #{reference}")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment