Project

General

Profile

Patch #29488 » 0001-adds-123-extended-issue-linking-syntax.patch

Jens Krämer, 2018-09-04 08:07

View differences:

app/helpers/application_helper.rb
830 830
  # Examples:
831 831
  #   Issues:
832 832
  #     #52 -> Link to issue #52
833
  #     ##52 -> Link to issue #52, including the issue's subject
833 834
  #   Changesets:
834 835
  #     r52 -> Link to revision 52
835 836
  #     commit:a85130f -> Link to scmid starting with a85130f
......
917 918
                               :title => truncate_single_line_raw(changeset.comments, 100))
918 919
              end
919 920
            end
920
          elsif sep == '#'
921
          elsif sep == '#' || sep == '##'
921 922
            oid = identifier.to_i
922 923
            case prefix
923 924
            when nil
924 925
              if oid.to_s == identifier &&
925 926
                issue = Issue.visible.find_by_id(oid)
926 927
                anchor = comment_id ? "note-#{comment_id}" : nil
927
                link = link_to("##{oid}#{comment_suffix}",
928
                               issue_url(issue, :only_path => only_path, :anchor => anchor),
929
                               :class => issue.css_classes,
930
                               :title => "#{issue.tracker.name}: #{issue.subject.truncate(100)} (#{issue.status.name})")
928
                url = issue_url(issue, :only_path => only_path, :anchor => anchor)
929
                link = if sep == '##'
930
                  link_to("#{issue.tracker.name} ##{oid}#{comment_suffix}",
931
                          url,
932
                          :class => issue.css_classes,
933
                          :title => "#{issue.tracker.name}: #{issue.subject.truncate(100)} (#{issue.status.name})") + ": #{issue.subject}"
934
                else
935
                  link_to("##{oid}#{comment_suffix}",
936
                          url,
937
                          :class => issue.css_classes,
938
                          :title => "#{issue.tracker.name}: #{issue.subject.truncate(100)} (#{issue.status.name})")
939
                end
931 940
              end
932 941
            when 'document'
933 942
              if document = Document.visible.find_by_id(oid)
......
1038 1047
            (?<prefix>attachment|document|version|forum|news|message|project|commit|source|export|user)?
1039 1048
            (
1040 1049
              (
1041
                (?<sep1>\#)|
1050
                (?<sep1>\#\#?)|
1042 1051
                (
1043 1052
                  (?<repo_prefix>(?<repo_identifier>[a-z0-9\-_]+)\|)?
1044 1053
                  (?<sep2>r)
test/helpers/application_helper_test.rb
290 290

  
291 291
    issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3},
292 292
                               :class => Issue.find(3).css_classes, :title => 'Bug: Error 281 when updating a recipe (New)')
293
    ext_issue_link = link_to('Bug #3', {:controller => 'issues', :action => 'show', :id => 3},
294
                               :class => Issue.find(3).css_classes, :title => 'Bug: Error 281 when updating a recipe (New)') + ": Error 281 when updating a recipe"
293 295
    note_link = link_to('#3-14', {:controller => 'issues', :action => 'show', :id => 3, :anchor => 'note-14'},
294 296
                               :class => Issue.find(3).css_classes, :title => 'Bug: Error 281 when updating a recipe (New)')
297
    ext_note_link = link_to('Bug #3-14', {:controller => 'issues', :action => 'show', :id => 3, :anchor => 'note-14'},
298
                               :class => Issue.find(3).css_classes, :title => 'Bug: Error 281 when updating a recipe (New)') + ": Error 281 when updating a recipe"
295 299
    note_link2 = link_to('#3#note-14', {:controller => 'issues', :action => 'show', :id => 3, :anchor => 'note-14'},
296 300
                               :class => Issue.find(3).css_classes, :title => 'Bug: Error 281 when updating a recipe (New)')
301
    ext_note_link2 = link_to('Bug #3#note-14', {:controller => 'issues', :action => 'show', :id => 3, :anchor => 'note-14'},
302
                               :class => Issue.find(3).css_classes, :title => 'Bug: Error 281 when updating a recipe (New)') + ": Error 281 when updating a recipe"
297 303

  
298 304
    revision_link = link_to('r1', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :repository_id => 10, :rev => 1},
299 305
                                   :class => 'changeset', :title => 'My very first commit do not escaping #<>&')
......
338 344
      '#3#note-14'                  => note_link2,
339 345
      # should not ignore leading zero
340 346
      '#03'                         => '#03',
347
      # tickets with more info
348
      '##3, [##3], (##3) and ##3.'      => "#{ext_issue_link}, [#{ext_issue_link}], (#{ext_issue_link}) and #{ext_issue_link}.",
349
      '##3-14'                       => ext_note_link,
350
      '##3#note-14'                  => ext_note_link2,
351
      '##03'                         => '##03',
341 352
      # changesets
342 353
      'r1'                          => revision_link,
343 354
      'r1.'                         => "#{revision_link}.",
(1-1/6)