Project

General

Profile

Actions

Feature #3346

closed

Support for cross-project revision links

Added by James Wells almost 15 years ago. Updated about 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Text formatting
Target version:
-
Start date:
2009-05-12
Due date:
% Done:

100%

Estimated time:
Resolution:
Duplicate

Description

It may sometimes be useful to be able to reference a specific repository revision in one project from another project, for example if an issue is partially addressed by a change in a sub-project. Whereas a revision link can be done with !r1234, a cross-project link could be done with r:project:1234.

The following patch shows how this could be done with relatively little change (although I haven't done much testing as to whether or not it breaks any other linking):

  Index: app/helpers/application_helper.rb
  ===================================================================
  --- app/helpers/application_helper.rb   (revision 2717)
  +++ app/helpers/application_helper.rb   (working copy)
  @@ -385,15 +385,25 @@
       #     export:some/file -> Force the download of the file
       #  Forum messages:
       #     message#1218 -> Link to message with id 1218
  -    text = text.gsub(%r{([\s\(,\-\>]|^)(!)?(attachment|document|version|commit|source|export|message)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|\s|<|$)}) do |m|
  -      leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8
  +    text = text.gsub(%r{([\s\(,\-\>]|^)(!)?(attachment|document|version|commit|source|export|message)?((#|r)(\:[^\:\s]+\:)?(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|\s|<|$)}) do |m|
  +      leading, esc, prefix, sep, revproj, oid = $1, $2, $3, $5 || $8, $6, $7 || $9
         link = nil
         if esc.nil?
           if prefix.nil? && sep == 'r'
  -          if project && (changeset = project.changesets.find_by_revision(oid))
  -            link = link_to("r#{oid}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => oid},
  +          if revproj.nil?
  +            if project && (changeset = project.changesets.find_by_revision(oid))
  +               link = link_to("r#{oid}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => oid},
  +                                       :class => 'changeset',
  +                                       :title => truncate_single_line(changeset.comments, 100))
  +            end
  +          else
  +            revproj.gsub!(/\:/,'')
  +            link_project = Project.find_by_name(revproj) || Project.find_by_identifier(revproj)
  +            if link_project && (changeset = link_project.changesets.find_by_revision(oid))
  +              link = link_to("r:#{revproj}:#{oid}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => link_project, :rev => oid},
                                         :class => 'changeset',
                                         :title => truncate_single_line(changeset.comments, 100))
  +            end
             end
           elsif sep == '#'
             oid = oid.to_i

Files

3346.diff (2.26 KB) 3346.diff James Wells, 2009-05-12 22:14
cross-project_revision_and_commit_links_v1.diff (4.17 KB) cross-project_revision_and_commit_links_v1.diff Support for cross-project revision and commit links v1 Babar O'Cap, 2009-08-18 12:39
cross-project_revision_and_commit_links_v2.diff (6.68 KB) cross-project_revision_and_commit_links_v2.diff Support for cross-project revision and commit links v2 Babar O'Cap, 2009-08-18 17:22
cross-project_revision_and_commit_links_v2.1.diff (6.34 KB) cross-project_revision_and_commit_links_v2.1.diff Patch v2.1 - accidentally revert r2833 in v2 Babar O'Cap, 2009-08-18 18:08
cross-project_revision_and_commit_links_v3.diff (5.3 KB) cross-project_revision_and_commit_links_v3.diff Patch v3 - Fix link_to_if_authorized and link_to_remote_if_authorized helpers because it breaks contextual links Babar O'Cap, 2009-08-20 09:26
cross-project_revision_and_commit_links_v4.diff (12.1 KB) cross-project_revision_and_commit_links_v4.diff Patch v4 - Adding unit tests and wiki syntax help - compatible with r2845 Babar O'Cap, 2009-08-20 12:31
cross-project_revision_and_commit_links_v5.diff (11.9 KB) cross-project_revision_and_commit_links_v5.diff Patch v5 - New wiki syntax, compatible with r2847 Babar O'Cap, 2009-08-26 10:27

Related issues

Related to Redmine - Defect #3087: Revision referring to issues across all projectsClosedJean-Philippe Lang2009-03-31

Actions
Related to Redmine - Feature #779: Multiple SCM per projectClosedJean-Philippe Lang2008-03-04

Actions
Related to Redmine - Feature #4052: Cross-project redmine links with alternate link text for source and export links.New2009-10-19

Actions
Has duplicate Redmine - Feature #3216: Reference to a revision from an other projectClosed2009-04-21

Actions
Is duplicate of Redmine - Feature #7409: Cross project Redmine linksClosed2011-01-22

Actions
Actions

Also available in: Atom PDF