@@ -52,19 +52,17 class Changeset < ActiveRecord::Base | |||
|
52 | 52 | def scan_comment_for_issue_ids |
|
53 | 53 | return if comments.blank? |
|
54 | 54 | # keywords used to reference issues |
|
55 | ref_keywords = Setting.commit_ref_keywords.downcase.split(",") | |
|
55 | ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip) | |
|
56 | 56 | # keywords used to fix issues |
|
57 | fix_keywords = Setting.commit_fix_keywords.downcase.split(",") | |
|
57 | fix_keywords = Setting.commit_fix_keywords.downcase.split(",").collect(&:strip) | |
|
58 | 58 | # status and optional done ratio applied |
|
59 | 59 | fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id) |
|
60 | 60 | done_ratio = Setting.commit_fix_done_ratio.blank? ? nil : Setting.commit_fix_done_ratio.to_i |
|
61 | 61 | |
|
62 |
kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw |
|
|
62 | kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|") | |
|
63 | 63 | return if kw_regexp.blank? |
|
64 | 64 | |
|
65 | # remove any associated issues | |
|
66 | self.issues.clear | |
|
67 | ||
|
65 | referenced_issues = [] | |
|
68 | 66 | comments.scan(Regexp.new("(#{kw_regexp})[\s:]+(([\s,;&]*#?\\d+)+)", Regexp::IGNORECASE)).each do |match| |
|
69 | 67 | action = match[0] |
|
70 | 68 | target_issue_ids = match[1].scan(/\d+/) |
@@ -80,7 +78,8 class Changeset < ActiveRecord::Base | |||
|
80 | 78 | issue.save |
|
81 | 79 | end |
|
82 | 80 | end |
|
83 |
|
|
|
81 | referenced_issues += target_issues | |
|
84 | 82 | end |
|
83 | self.issues = referenced_issues.uniq | |
|
85 | 84 | end |
|
86 | 85 | end |
@@ -12,7 +12,7 changesets_002: | |||
|
12 | 12 | committed_on: 2007-04-12 15:14:44 +02:00 |
|
13 | 13 | revision: 2 |
|
14 | 14 | id: 101 |
|
15 | comments: 'This commit fixes #1, #2 and references #3' | |
|
15 | comments: 'This commit fixes #1, #2 and references #1 & #3' | |
|
16 | 16 | repository_id: 10 |
|
17 | 17 | committer: dlopper |
|
18 | 18 | changesets_003: |
@@ -40,6 +40,8 class RepositoryTest < Test::Unit::TestCase | |||
|
40 | 40 | # choosing a status to apply to fix issues |
|
41 | 41 | Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id |
|
42 | 42 | Setting.commit_fix_done_ratio = "90" |
|
43 | Setting.commit_ref_keywords = 'refs , references, IssueID' | |
|
44 | Setting.commit_fix_keywords = 'fixes , closes' | |
|
43 | 45 | |
|
44 | 46 | # make sure issue 1 is not already closed |
|
45 | 47 | assert !Issue.find(1).status.is_closed? |
General Comments 0
You need to be logged in to leave comments.
Login now