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