summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-02-05 10:43:34 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-02-05 10:43:34 +0000
commit5ac4eddbbf44b8bff0b0998fb93a2b9d882d0114 (patch)
treed82322eca6501a68cf502241c5e0f9bb8fdf7619 /app/services
parentf5990e444a98dc259e2af8c373910cd9ec15b0bd (diff)
parent25262ed2ec0caa62a5325773b0cdb3c0517b6dd1 (diff)
downloadgitlab-ce-5ac4eddbbf44b8bff0b0998fb93a2b9d882d0114.tar.gz
Merge branch 'osw-markdown-bypass-for-commit-messages' into 'master'
Bypass markdown for commit titles on MR notes Closes #37616 See merge request gitlab-org/gitlab-ce!16883
Diffstat (limited to 'app/services')
-rw-r--r--app/services/system_note_service.rb26
1 files changed, 18 insertions, 8 deletions
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb
index 06b23cd7076..2253d638e93 100644
--- a/app/services/system_note_service.rb
+++ b/app/services/system_note_service.rb
@@ -22,8 +22,7 @@ module SystemNoteService
commits_text = "#{total_count} commit".pluralize(total_count)
body = "added #{commits_text}\n\n"
- body << existing_commit_summary(noteable, existing_commits, oldrev)
- body << new_commit_summary(new_commits).join("\n")
+ body << commits_list(noteable, new_commits, existing_commits, oldrev)
body << "\n\n[Compare with previous version](#{diff_comparison_url(noteable, project, oldrev)})"
create_note(NoteSummary.new(noteable, project, author, body, action: 'commit', commit_count: total_count))
@@ -481,7 +480,7 @@ module SystemNoteService
# Returns an Array of Strings
def new_commit_summary(new_commits)
new_commits.collect do |commit|
- "* #{commit.short_id} - #{escape_html(commit.title)}"
+ content_tag('li', "#{commit.short_id} - #{commit.title}")
end
end
@@ -604,6 +603,16 @@ module SystemNoteService
"#{cross_reference_note_prefix}#{gfm_reference}"
end
+ # Builds a list of existing and new commits according to existing_commits and
+ # new_commits methods.
+ # Returns a String wrapped in `ul` and `li` tags.
+ def commits_list(noteable, new_commits, existing_commits, oldrev)
+ existing_commit_summary = existing_commit_summary(noteable, existing_commits, oldrev)
+ new_commit_summary = new_commit_summary(new_commits).join
+
+ content_tag('ul', "#{existing_commit_summary}#{new_commit_summary}".html_safe)
+ end
+
# Build a single line summarizing existing commits being added in a merge
# request
#
@@ -640,11 +649,8 @@ module SystemNoteService
branch = noteable.target_branch
branch = "#{noteable.target_project_namespace}:#{branch}" if noteable.for_fork?
- "* #{commit_ids} - #{commits_text} from branch `#{branch}`\n"
- end
-
- def escape_html(text)
- Rack::Utils.escape_html(text)
+ branch_name = content_tag('code', branch)
+ content_tag('li', "#{commit_ids} - #{commits_text} from branch #{branch_name}".html_safe)
end
def url_helpers
@@ -661,4 +667,8 @@ module SystemNoteService
start_sha: oldrev
)
end
+
+ def content_tag(*args)
+ ActionController::Base.helpers.content_tag(*args)
+ end
end