def scan_comment_for_issue_ids
return if comments.blank?
# keywords used to reference issues
- ref_keywords = Setting.commit_ref_keywords.downcase.split(",")
+ ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip)
# keywords used to fix issues
- fix_keywords = Setting.commit_fix_keywords.downcase.split(",")
+ fix_keywords = Setting.commit_fix_keywords.downcase.split(",").collect(&:strip)
# status and optional done ratio applied
fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id)
done_ratio = Setting.commit_fix_done_ratio.blank? ? nil : Setting.commit_fix_done_ratio.to_i
- kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw.strip)}.join("|")
+ kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|")
return if kw_regexp.blank?
- # remove any associated issues
- self.issues.clear
-
+ referenced_issues = []
comments.scan(Regexp.new("(#{kw_regexp})[\s:]+(([\s,;&]*#?\\d+)+)", Regexp::IGNORECASE)).each do |match|
action = match[0]
target_issue_ids = match[1].scan(/\d+/)
issue.save
end
end
- self.issues << target_issues
+ referenced_issues += target_issues
end
+ self.issues = referenced_issues.uniq
end
end
committed_on: 2007-04-12 15:14:44 +02:00\r
revision: 2\r
id: 101\r
- comments: 'This commit fixes #1, #2 and references #3'\r
+ comments: 'This commit fixes #1, #2 and references #1 & #3'\r
repository_id: 10\r
committer: dlopper\r
changesets_003: \r
# choosing a status to apply to fix issues
Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id
Setting.commit_fix_done_ratio = "90"
+ Setting.commit_ref_keywords = 'refs , references, IssueID'
+ Setting.commit_fix_keywords = 'fixes , closes'
# make sure issue 1 is not already closed
assert !Issue.find(1).status.is_closed?