@@ -659,7 +659,7 module ApplicationHelper | |||||
659 | # identifier:version:1.0.0 |
|
659 | # identifier:version:1.0.0 | |
660 | # identifier:source:some/file |
|
660 | # identifier:source:some/file | |
661 | def parse_redmine_links(text, default_project, obj, attr, only_path, options) |
|
661 | def parse_redmine_links(text, default_project, obj, attr, only_path, options) | |
662 | text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m| |
|
662 | text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-_]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m| | |
663 | leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $1, $2, $3, $4, $5, $10, $11, $8 || $12 || $18, $14 || $19, $15, $17 |
|
663 | leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $1, $2, $3, $4, $5, $10, $11, $8 || $12 || $18, $14 || $19, $15, $17 | |
664 | link = nil |
|
664 | link = nil | |
665 | project = default_project |
|
665 | project = default_project | |
@@ -748,7 +748,7 module ApplicationHelper | |||||
748 | when 'commit', 'source', 'export' |
|
748 | when 'commit', 'source', 'export' | |
749 | if project |
|
749 | if project | |
750 | repository = nil |
|
750 | repository = nil | |
751 | if name =~ %r{^(([a-z0-9\-]+)\|)(.+)$} |
|
751 | if name =~ %r{^(([a-z0-9\-_]+)\|)(.+)$} | |
752 | repo_prefix, repo_identifier, name = $1, $2, $3 |
|
752 | repo_prefix, repo_identifier, name = $1, $2, $3 | |
753 | repository = project.repositories.detect {|repo| repo.identifier == repo_identifier} |
|
753 | repository = project.repositories.detect {|repo| repo.identifier == repo_identifier} | |
754 | else |
|
754 | else |
@@ -408,14 +408,14 RAW | |||||
408 | end |
|
408 | end | |
409 |
|
409 | |||
410 | def test_multiple_repositories_redmine_links |
|
410 | def test_multiple_repositories_redmine_links | |
411 | svn = Repository::Subversion.create!(:project_id => 1, :identifier => 'svn1', :url => 'file:///foo/hg') |
|
411 | svn = Repository::Subversion.create!(:project_id => 1, :identifier => 'svn_repo-1', :url => 'file:///foo/hg') | |
412 | Changeset.create!(:repository => svn, :committed_on => Time.now, :revision => '123') |
|
412 | Changeset.create!(:repository => svn, :committed_on => Time.now, :revision => '123') | |
413 | hg = Repository::Mercurial.create!(:project_id => 1, :identifier => 'hg1', :url => '/foo/hg') |
|
413 | hg = Repository::Mercurial.create!(:project_id => 1, :identifier => 'hg1', :url => '/foo/hg') | |
414 | Changeset.create!(:repository => hg, :committed_on => Time.now, :revision => '123', :scmid => 'abcd') |
|
414 | Changeset.create!(:repository => hg, :committed_on => Time.now, :revision => '123', :scmid => 'abcd') | |
415 |
|
415 | |||
416 | changeset_link = link_to('r2', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 2}, |
|
416 | changeset_link = link_to('r2', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 2}, | |
417 | :class => 'changeset', :title => 'This commit fixes #1, #2 and references #1 & #3') |
|
417 | :class => 'changeset', :title => 'This commit fixes #1, #2 and references #1 & #3') | |
418 | svn_changeset_link = link_to('svn1|r123', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :repository_id => 'svn1', :rev => 123}, |
|
418 | svn_changeset_link = link_to('svn_repo-1|r123', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :repository_id => 'svn_repo-1', :rev => 123}, | |
419 | :class => 'changeset', :title => '') |
|
419 | :class => 'changeset', :title => '') | |
420 | hg_changeset_link = link_to('hg1|abcd', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :repository_id => 'hg1', :rev => 'abcd'}, |
|
420 | hg_changeset_link = link_to('hg1|abcd', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :repository_id => 'hg1', :rev => 'abcd'}, | |
421 | :class => 'changeset', :title => '') |
|
421 | :class => 'changeset', :title => '') | |
@@ -425,7 +425,7 RAW | |||||
425 |
|
425 | |||
426 | to_test = { |
|
426 | to_test = { | |
427 | 'r2' => changeset_link, |
|
427 | 'r2' => changeset_link, | |
428 |
'svn1|r123' |
|
428 | 'svn_repo-1|r123' => svn_changeset_link, | |
429 | 'invalid|r123' => 'invalid|r123', |
|
429 | 'invalid|r123' => 'invalid|r123', | |
430 | 'commit:hg1|abcd' => hg_changeset_link, |
|
430 | 'commit:hg1|abcd' => hg_changeset_link, | |
431 | 'commit:invalid|abcd' => 'commit:invalid|abcd', |
|
431 | 'commit:invalid|abcd' => 'commit:invalid|abcd', |
General Comments 0
You need to be logged in to leave comments.
Login now