summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2018-09-08 06:43:13 +0000
committerGo MAEDA <maeda@farend.jp>2018-09-08 06:43:13 +0000
commit60ee5e109ee069f1c5ebd0af7f8fee08ff294d07 (patch)
tree9086be156a30a17aa707935ebaf0aad725e82c06
parent2cffbf1d45e0ccabc338adb583284dfe437b9b22 (diff)
downloadredmine-60ee5e109ee069f1c5ebd0af7f8fee08ff294d07.tar.gz
redmine-60ee5e109ee069f1c5ebd0af7f8fee08ff294d07.zip
Adds ##123 extended issue linking syntax (#29488).
Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@17478 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/application_helper.rb21
-rw-r--r--test/helpers/application_helper_test.rb11
2 files changed, 26 insertions, 6 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 58b988454..546080386 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -830,6 +830,7 @@ module ApplicationHelper
# Examples:
# Issues:
# #52 -> Link to issue #52
+ # ##52 -> Link to issue #52, including the issue's subject
# Changesets:
# r52 -> Link to revision 52
# commit:a85130f -> Link to scmid starting with a85130f
@@ -917,17 +918,25 @@ module ApplicationHelper
:title => truncate_single_line_raw(changeset.comments, 100))
end
end
- elsif sep == '#'
+ elsif sep == '#' || sep == '##'
oid = identifier.to_i
case prefix
when nil
if oid.to_s == identifier &&
issue = Issue.visible.find_by_id(oid)
anchor = comment_id ? "note-#{comment_id}" : nil
- link = link_to("##{oid}#{comment_suffix}",
- issue_url(issue, :only_path => only_path, :anchor => anchor),
- :class => issue.css_classes,
- :title => "#{issue.tracker.name}: #{issue.subject.truncate(100)} (#{issue.status.name})")
+ url = issue_url(issue, :only_path => only_path, :anchor => anchor)
+ link = if sep == '##'
+ link_to("#{issue.tracker.name} ##{oid}#{comment_suffix}",
+ url,
+ :class => issue.css_classes,
+ :title => "#{issue.tracker.name}: #{issue.subject.truncate(100)} (#{issue.status.name})") + ": #{issue.subject}"
+ else
+ link_to("##{oid}#{comment_suffix}",
+ url,
+ :class => issue.css_classes,
+ :title => "#{issue.tracker.name}: #{issue.subject.truncate(100)} (#{issue.status.name})")
+ end
end
when 'document'
if document = Document.visible.find_by_id(oid)
@@ -1038,7 +1047,7 @@ module ApplicationHelper
(?<prefix>attachment|document|version|forum|news|message|project|commit|source|export|user)?
(
(
- (?<sep1>\#)|
+ (?<sep1>\#\#?)|
(
(?<repo_prefix>(?<repo_identifier>[a-z0-9\-_]+)\|)?
(?<sep2>r)
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index aa403be46..0a4c32077 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -290,10 +290,16 @@ RAW
issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3},
:class => Issue.find(3).css_classes, :title => 'Bug: Error 281 when updating a recipe (New)')
+ ext_issue_link = link_to('Bug #3', {:controller => 'issues', :action => 'show', :id => 3},
+ :class => Issue.find(3).css_classes, :title => 'Bug: Error 281 when updating a recipe (New)') + ": Error 281 when updating a recipe"
note_link = link_to('#3-14', {:controller => 'issues', :action => 'show', :id => 3, :anchor => 'note-14'},
:class => Issue.find(3).css_classes, :title => 'Bug: Error 281 when updating a recipe (New)')
+ ext_note_link = link_to('Bug #3-14', {:controller => 'issues', :action => 'show', :id => 3, :anchor => 'note-14'},
+ :class => Issue.find(3).css_classes, :title => 'Bug: Error 281 when updating a recipe (New)') + ": Error 281 when updating a recipe"
note_link2 = link_to('#3#note-14', {:controller => 'issues', :action => 'show', :id => 3, :anchor => 'note-14'},
:class => Issue.find(3).css_classes, :title => 'Bug: Error 281 when updating a recipe (New)')
+ ext_note_link2 = link_to('Bug #3#note-14', {:controller => 'issues', :action => 'show', :id => 3, :anchor => 'note-14'},
+ :class => Issue.find(3).css_classes, :title => 'Bug: Error 281 when updating a recipe (New)') + ": Error 281 when updating a recipe"
revision_link = link_to('r1', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :repository_id => 10, :rev => 1},
:class => 'changeset', :title => 'My very first commit do not escaping #<>&')
@@ -338,6 +344,11 @@ RAW
'#3#note-14' => note_link2,
# should not ignore leading zero
'#03' => '#03',
+ # tickets with more info
+ '##3, [##3], (##3) and ##3.' => "#{ext_issue_link}, [#{ext_issue_link}], (#{ext_issue_link}) and #{ext_issue_link}.",
+ '##3-14' => ext_note_link,
+ '##3#note-14' => ext_note_link2,
+ '##03' => '##03',
# changesets
'r1' => revision_link,
'r1.' => "#{revision_link}.",