diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-10-22 16:52:36 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-10-22 16:52:36 +0000 |
commit | b30b6717a271f06290c07479b7e26446f039e4df (patch) | |
tree | d82ff9611faeef92d286e756d2448236ce094093 /app/models | |
parent | cedca57620e36fc8deb22653e91ef3e63fe63cf2 (diff) | |
download | redmine-b30b6717a271f06290c07479b7e26446f039e4df.tar.gz redmine-b30b6717a271f06290c07479b7e26446f039e4df.zip |
Commit message parser:
* Fixed: Error when parsing a commit message with duplicate issue identifiers
* Strip referencing and fixing keywords
git-svn-id: http://redmine.rubyforge.org/svn/trunk@861 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/changeset.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 21e14fc0d..e4e221732 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -52,19 +52,17 @@ class Changeset < ActiveRecord::Base 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+/) @@ -80,7 +78,8 @@ class Changeset < ActiveRecord::Base issue.save end end - self.issues << target_issues + referenced_issues += target_issues end + self.issues = referenced_issues.uniq end end |