@@ -84,9 +84,6 class Changeset < ActiveRecord::Base | |||
|
84 | 84 | ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip) |
|
85 | 85 | # keywords used to fix issues |
|
86 | 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 | 88 | kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|") |
|
92 | 89 | return if kw_regexp.blank? |
@@ -104,7 +101,7 class Changeset < ActiveRecord::Base | |||
|
104 | 101 | action = match[0] |
|
105 | 102 | target_issue_ids = match[1].scan(/\d+/) |
|
106 | 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 | 105 | # update status of issues |
|
109 | 106 | logger.debug "Issues fixed by changeset #{self.revision}: #{issue_ids.join(', ')}." if logger && logger.debug? |
|
110 | 107 | target_issues.each do |issue| |
@@ -118,7 +115,9 class Changeset < ActiveRecord::Base | |||
|
118 | 115 | end |
|
119 | 116 | journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, csettext)) |
|
120 | 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 | 121 | Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update, |
|
123 | 122 | { :changeset => self, :issue => issue }) |
|
124 | 123 | issue.save |
@@ -127,7 +126,8 class Changeset < ActiveRecord::Base | |||
|
127 | 126 | referenced_issues += target_issues |
|
128 | 127 | end |
|
129 | 128 | |
|
130 |
|
|
|
129 | referenced_issues.uniq! | |
|
130 | self.issues = referenced_issues unless referenced_issues.empty? | |
|
131 | 131 | end |
|
132 | 132 | |
|
133 | 133 | def short_comments |
@@ -158,6 +158,7 class Changeset < ActiveRecord::Base | |||
|
158 | 158 | # Finds issues that can be referenced by the commit message |
|
159 | 159 | # i.e. issues that belong to the repository project, a subproject or a parent project |
|
160 | 160 | def find_referenced_issues_by_id(ids) |
|
161 | return [] if ids.compact.empty? | |
|
161 | 162 | Issue.find_all_by_id(ids, :include => :project).select {|issue| |
|
162 | 163 | project == issue.project || project.is_ancestor_of?(issue.project) || project.is_descendant_of?(issue.project) |
|
163 | 164 | } |
@@ -136,6 +136,7 class Repository < ActiveRecord::Base | |||
|
136 | 136 | end |
|
137 | 137 | end |
|
138 | 138 | @committers = nil |
|
139 | @found_committer_users = nil | |
|
139 | 140 | true |
|
140 | 141 | else |
|
141 | 142 | false |
@@ -146,16 +147,22 class Repository < ActiveRecord::Base | |||
|
146 | 147 | # It will return nil if the committer is not yet mapped and if no User |
|
147 | 148 | # with the same username or email was found |
|
148 | 149 | def find_committer_user(committer) |
|
149 |
|
|
|
150 | unless committer.blank? | |
|
151 | @found_committer_users ||= {} | |
|
152 | return @found_committer_users[committer] if @found_committer_users.has_key?(committer) | |
|
153 | ||
|
154 | user = nil | |
|
150 | 155 | c = changesets.find(:first, :conditions => {:committer => committer}, :include => :user) |
|
151 | 156 | if c && c.user |
|
152 | c.user | |
|
157 | user = c.user | |
|
153 | 158 | elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/ |
|
154 | 159 | username, email = $1.strip, $3 |
|
155 | 160 | u = User.find_by_login(username) |
|
156 | 161 | u ||= User.find_by_mail(email) unless email.blank? |
|
157 | u | |
|
162 | user = u | |
|
158 | 163 | end |
|
164 | @found_committer_users[committer] = user | |
|
165 | user | |
|
159 | 166 | end |
|
160 | 167 | end |
|
161 | 168 |
@@ -286,21 +286,23 module Redmine | |||
|
286 | 286 | end |
|
287 | 287 | |
|
288 | 288 | def save(repo) |
|
289 | if repo.changesets.find_by_scmid(scmid.to_s).nil? | |
|
290 |
changeset = Changeset. |
|
|
289 | Changeset.transaction do | |
|
290 | changeset = Changeset.new( | |
|
291 | 291 | :repository => repo, |
|
292 | 292 | :revision => identifier, |
|
293 | 293 | :scmid => scmid, |
|
294 | 294 | :committer => author, |
|
295 | 295 | :committed_on => time, |
|
296 | 296 | :comments => message) |
|
297 | ||
|
298 | paths.each do |file| | |
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
|
303 | end | |
|
297 | ||
|
298 | if changeset.save | |
|
299 | paths.each do |file| | |
|
300 | Change.create( | |
|
301 | :changeset => changeset, | |
|
302 | :action => file[:action], | |
|
303 | :path => file[:path]) | |
|
304 | end | |
|
305 | end | |
|
304 | 306 | end |
|
305 | 307 | end |
|
306 | 308 | end |
General Comments 0
You need to be logged in to leave comments.
Login now