Allow referencing issue numbers in brackets. This style is used by other
bug trackers. Examples: * "[#nnn] Worked on this issue" * "[#nnn, #mmm] Worked on these" * "[#nnn #mmm] Working some more" git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2854 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
cd1e094ce8
commit
609faba6a3
|
@ -89,7 +89,7 @@ class Changeset < ActiveRecord::Base
|
||||||
if ref_keywords.delete('*')
|
if ref_keywords.delete('*')
|
||||||
# find any issue ID in the comments
|
# find any issue ID in the comments
|
||||||
target_issue_ids = []
|
target_issue_ids = []
|
||||||
comments.scan(%r{([\s\(,-]|^)#(\d+)(?=[[:punct:]]|\s|<|$)}).each { |m| target_issue_ids << m[1] }
|
comments.scan(%r{([\s\(\[,-]|^)#(\d+)(?=[[:punct:]]|\s|<|$)}).each { |m| target_issue_ids << m[1] }
|
||||||
referenced_issues += repository.project.issues.find_all_by_id(target_issue_ids)
|
referenced_issues += repository.project.issues.find_all_by_id(target_issue_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,28 @@ class ChangesetTest < Test::Unit::TestCase
|
||||||
assert_equal [1], c.issue_ids.sort
|
assert_equal [1], c.issue_ids.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_ref_keywords_allow_brackets_around_a_issue_number
|
||||||
|
Setting.commit_ref_keywords = '*'
|
||||||
|
|
||||||
|
c = Changeset.new(:repository => Project.find(1).repository,
|
||||||
|
:committed_on => Time.now,
|
||||||
|
:comments => '[#1] Worked on this issue')
|
||||||
|
c.scan_comment_for_issue_ids
|
||||||
|
|
||||||
|
assert_equal [1], c.issue_ids.sort
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ref_keywords_allow_brackets_around_multiple_issue_numbers
|
||||||
|
Setting.commit_ref_keywords = '*'
|
||||||
|
|
||||||
|
c = Changeset.new(:repository => Project.find(1).repository,
|
||||||
|
:committed_on => Time.now,
|
||||||
|
:comments => '[#1 #2, #3] Worked on these')
|
||||||
|
c.scan_comment_for_issue_ids
|
||||||
|
|
||||||
|
assert_equal [1,2,3], c.issue_ids.sort
|
||||||
|
end
|
||||||
|
|
||||||
def test_previous
|
def test_previous
|
||||||
changeset = Changeset.find_by_revision('3')
|
changeset = Changeset.find_by_revision('3')
|
||||||
assert_equal Changeset.find_by_revision('2'), changeset.previous
|
assert_equal Changeset.find_by_revision('2'), changeset.previous
|
||||||
|
|
Loading…
Reference in New Issue