From e8d092e46ad8c77419792cc5b418251a1c0a09c6 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 25 May 2008 11:43:20 +0000 Subject: [PATCH] Fixed: using '*' as keyword for repository referencing keywords doesn't work when issue id is at the beginning of a line (#1253). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1451 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/changeset.rb | 2 +- test/unit/changeset_test.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 9a05e6a68..41f5ed86a 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -75,7 +75,7 @@ class Changeset < ActiveRecord::Base if ref_keywords.delete('*') # find any issue ID in the comments 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) end diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb index bbfe6952d..6cc53d852 100644 --- a/test/unit/changeset_test.rb +++ b/test/unit/changeset_test.rb @@ -39,6 +39,17 @@ class ChangesetTest < Test::Unit::TestCase assert fixed.closed? assert_equal 90, fixed.done_ratio end + + def test_ref_keywords_any_line_start + Setting.commit_ref_keywords = '*' + + c = Changeset.new(:repository => Project.find(1).repository, + :committed_on => Time.now, + :comments => '#1 is the reason of this commit') + c.scan_comment_for_issue_ids + + assert_equal [1], c.issue_ids.sort + end def test_previous changeset = Changeset.find_by_revision('3')