summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-03-12 09:11:59 -0700
committerStan Hu <stanhu@gmail.com>2015-03-19 07:07:30 -0700
commitfad71576f91beb4aae8e8482465a696cdfc3b222 (patch)
treefb49dc03811db01f1a66fe21ba7dfaac2fb6337a /app/models/note.rb
parent6c1074e302fd77e87c454cede145dd92f15d0c55 (diff)
downloadgitlab-ce-fad71576f91beb4aae8e8482465a696cdfc3b222.tar.gz
Fix cross references when usernames, milestones, or project names contain underscores.
Remove emphasis from system notes to avoid Markdown conflicts in names.
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb25
1 files changed, 15 insertions, 10 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 649e9b4e852..27b583a869a 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -59,7 +59,7 @@ class Note < ActiveRecord::Base
class << self
def create_status_change_note(noteable, project, author, status, source)
- body = "_Status changed to #{status}#{' by ' + source.gfm_reference if source}_"
+ body = "Status changed to #{status}#{' by ' + source.gfm_reference if source}"
create(
noteable: noteable,
@@ -95,9 +95,9 @@ class Note < ActiveRecord::Base
def create_milestone_change_note(noteable, project, author, milestone)
body = if milestone.nil?
- '_Milestone removed_'
+ 'Milestone removed'
else
- "_Milestone changed to #{milestone.title}_"
+ "Milestone changed to #{milestone.title}"
end
create(
@@ -110,7 +110,7 @@ class Note < ActiveRecord::Base
end
def create_assignee_change_note(noteable, project, author, assignee)
- body = assignee.nil? ? '_Assignee removed_' : "_Reassigned to @#{assignee.username}_"
+ body = assignee.nil? ? 'Assignee removed' : "Reassigned to @#{assignee.username}"
create({
noteable: noteable,
@@ -140,7 +140,7 @@ class Note < ActiveRecord::Base
end
message << ' ' << 'label'.pluralize(labels_count)
- body = "_#{message.capitalize}_"
+ body = "#{message.capitalize}"
create(
noteable: noteable,
@@ -170,14 +170,14 @@ class Note < ActiveRecord::Base
commits_text = ActionController::Base.helpers.pluralize(existing_commits.length, 'commit')
- branch =
+ branch =
if merge_request.for_fork?
"#{merge_request.target_project_namespace}:#{merge_request.target_branch}"
else
merge_request.target_branch
end
- message = "* #{commit_ids} - _#{commits_text} from branch `#{branch}`_"
+ message = "* #{commit_ids} - #{commits_text} from branch `#{branch}`"
body << message
body << "\n"
end
@@ -240,7 +240,7 @@ class Note < ActiveRecord::Base
where(noteable_id: noteable.id)
end
- notes.where('note like ?', cross_reference_note_content(gfm_reference)).
+ notes.where('note like ?', cross_reference_note_pattern(gfm_reference)).
system.any?
end
@@ -249,13 +249,18 @@ class Note < ActiveRecord::Base
end
def cross_reference_note_prefix
- '_mentioned in '
+ 'mentioned in '
end
private
def cross_reference_note_content(gfm_reference)
- cross_reference_note_prefix + "#{gfm_reference}_"
+ cross_reference_note_prefix + "#{gfm_reference}"
+ end
+
+ def cross_reference_note_pattern(gfm_reference)
+ # Older cross reference notes contained underscores for emphasis
+ "%" + cross_reference_note_content(gfm_reference) + "%"
end
# Prepend the mentioner's namespaced project path to the GFM reference for