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
This commit is contained in:
Robert Speicher 2018-07-03 15:31:16 +00:00
commit acc6e3a0fd
4 changed files with 22 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
title: Use monospaced font for MR diff commit link ref on GFM
merge_request:
author:
type: other

View file

@ -25,7 +25,10 @@ module Banzai
extras = super
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
path = matches[:path] if matches.names.include?("path")

View file

@ -65,8 +65,12 @@ module Banzai
context[:skip_project_check]
end
def reference_class(type)
"gfm gfm-#{type} has-tooltip"
def reference_class(type, tooltip: true)
gfm_klass = "gfm gfm-#{type}"
return gfm_klass unless tooltip
"#{gfm_klass} has-tooltip"
end
# Ensure that a :project key exists in context

View file

@ -210,6 +210,13 @@ describe Banzai::Filter::MergeRequestReferenceFilter do
.to eq reference
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
doc = reference_filter("See #{reference}")