@@ -84,9 +84,6 class Changeset < ActiveRecord::Base | |||||
84 | ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip) |
|
84 | ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip) | |
85 | # keywords used to fix issues |
|
85 | # keywords used to fix issues | |
86 | fix_keywords = Setting.commit_fix_keywords.downcase.split(",").collect(&:strip) |
|
86 | fix_keywords = Setting.commit_fix_keywords.downcase.split(",").collect(&:strip) | |
87 | # status and optional done ratio applied |
|
|||
88 | fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id) |
|
|||
89 | done_ratio = Setting.commit_fix_done_ratio.blank? ? nil : Setting.commit_fix_done_ratio.to_i |
|
|||
90 |
|
87 | |||
91 | kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|") |
|
88 | kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|") | |
92 | return if kw_regexp.blank? |
|
89 | return if kw_regexp.blank? | |
@@ -104,7 +101,7 class Changeset < ActiveRecord::Base | |||||
104 | action = match[0] |
|
101 | action = match[0] | |
105 | target_issue_ids = match[1].scan(/\d+/) |
|
102 | target_issue_ids = match[1].scan(/\d+/) | |
106 | target_issues = find_referenced_issues_by_id(target_issue_ids) |
|
103 | target_issues = find_referenced_issues_by_id(target_issue_ids) | |
107 | if fix_status && fix_keywords.include?(action.downcase) |
|
104 | if fix_keywords.include?(action.downcase) && fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id) | |
108 | # update status of issues |
|
105 | # update status of issues | |
109 | logger.debug "Issues fixed by changeset #{self.revision}: #{issue_ids.join(', ')}." if logger && logger.debug? |
|
106 | logger.debug "Issues fixed by changeset #{self.revision}: #{issue_ids.join(', ')}." if logger && logger.debug? | |
110 | target_issues.each do |issue| |
|
107 | target_issues.each do |issue| | |
@@ -118,7 +115,9 class Changeset < ActiveRecord::Base | |||||
118 | end |
|
115 | end | |
119 | journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, csettext)) |
|
116 | journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, csettext)) | |
120 | issue.status = fix_status |
|
117 | issue.status = fix_status | |
121 | issue.done_ratio = done_ratio if done_ratio |
|
118 | unless Setting.commit_fix_done_ratio.blank? | |
|
119 | issue.done_ratio = Setting.commit_fix_done_ratio.to_i | |||
|
120 | end | |||
122 | Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update, |
|
121 | Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update, | |
123 | { :changeset => self, :issue => issue }) |
|
122 | { :changeset => self, :issue => issue }) | |
124 | issue.save |
|
123 | issue.save | |
@@ -127,7 +126,8 class Changeset < ActiveRecord::Base | |||||
127 | referenced_issues += target_issues |
|
126 | referenced_issues += target_issues | |
128 | end |
|
127 | end | |
129 |
|
128 | |||
130 |
|
|
129 | referenced_issues.uniq! | |
|
130 | self.issues = referenced_issues unless referenced_issues.empty? | |||
131 | end |
|
131 | end | |
132 |
|
132 | |||
133 | def short_comments |
|
133 | def short_comments | |
@@ -167,6 +167,7 class Changeset < ActiveRecord::Base | |||||
167 | # Finds issues that can be referenced by the commit message |
|
167 | # Finds issues that can be referenced by the commit message | |
168 | # i.e. issues that belong to the repository project, a subproject or a parent project |
|
168 | # i.e. issues that belong to the repository project, a subproject or a parent project | |
169 | def find_referenced_issues_by_id(ids) |
|
169 | def find_referenced_issues_by_id(ids) | |
|
170 | return [] if ids.compact.empty? | |||
170 | Issue.find_all_by_id(ids, :include => :project).select {|issue| |
|
171 | Issue.find_all_by_id(ids, :include => :project).select {|issue| | |
171 | project == issue.project || project.is_ancestor_of?(issue.project) || project.is_descendant_of?(issue.project) |
|
172 | project == issue.project || project.is_ancestor_of?(issue.project) || project.is_descendant_of?(issue.project) | |
172 | } |
|
173 | } |
General Comments 0
You need to be logged in to leave comments.
Login now