mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Merged r3469, r3472 and r3473 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3505 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
aacabbe645
commit
d80fb751fd
@ -84,9 +84,6 @@ class Changeset < ActiveRecord::Base
|
|||||||
ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip)
|
ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip)
|
||||||
# keywords used to fix issues
|
# keywords used to fix issues
|
||||||
fix_keywords = Setting.commit_fix_keywords.downcase.split(",").collect(&:strip)
|
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)}.join("|")
|
kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|")
|
||||||
return if kw_regexp.blank?
|
return if kw_regexp.blank?
|
||||||
@ -104,7 +101,7 @@ class Changeset < ActiveRecord::Base
|
|||||||
action = match[0]
|
action = match[0]
|
||||||
target_issue_ids = match[1].scan(/\d+/)
|
target_issue_ids = match[1].scan(/\d+/)
|
||||||
target_issues = find_referenced_issues_by_id(target_issue_ids)
|
target_issues = find_referenced_issues_by_id(target_issue_ids)
|
||||||
if fix_status && fix_keywords.include?(action.downcase)
|
if fix_keywords.include?(action.downcase) && fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id)
|
||||||
# update status of issues
|
# update status of issues
|
||||||
logger.debug "Issues fixed by changeset #{self.revision}: #{issue_ids.join(', ')}." if logger && logger.debug?
|
logger.debug "Issues fixed by changeset #{self.revision}: #{issue_ids.join(', ')}." if logger && logger.debug?
|
||||||
target_issues.each do |issue|
|
target_issues.each do |issue|
|
||||||
@ -118,7 +115,9 @@ class Changeset < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, csettext))
|
journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, csettext))
|
||||||
issue.status = fix_status
|
issue.status = fix_status
|
||||||
issue.done_ratio = done_ratio if done_ratio
|
unless Setting.commit_fix_done_ratio.blank?
|
||||||
|
issue.done_ratio = Setting.commit_fix_done_ratio.to_i
|
||||||
|
end
|
||||||
Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update,
|
Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update,
|
||||||
{ :changeset => self, :issue => issue })
|
{ :changeset => self, :issue => issue })
|
||||||
issue.save
|
issue.save
|
||||||
@ -127,7 +126,8 @@ class Changeset < ActiveRecord::Base
|
|||||||
referenced_issues += target_issues
|
referenced_issues += target_issues
|
||||||
end
|
end
|
||||||
|
|
||||||
self.issues = referenced_issues.uniq
|
referenced_issues.uniq!
|
||||||
|
self.issues = referenced_issues unless referenced_issues.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def short_comments
|
def short_comments
|
||||||
@ -158,6 +158,7 @@ class Changeset < ActiveRecord::Base
|
|||||||
# Finds issues that can be referenced by the commit message
|
# Finds issues that can be referenced by the commit message
|
||||||
# i.e. issues that belong to the repository project, a subproject or a parent project
|
# i.e. issues that belong to the repository project, a subproject or a parent project
|
||||||
def find_referenced_issues_by_id(ids)
|
def find_referenced_issues_by_id(ids)
|
||||||
|
return [] if ids.compact.empty?
|
||||||
Issue.find_all_by_id(ids, :include => :project).select {|issue|
|
Issue.find_all_by_id(ids, :include => :project).select {|issue|
|
||||||
project == issue.project || project.is_ancestor_of?(issue.project) || project.is_descendant_of?(issue.project)
|
project == issue.project || project.is_ancestor_of?(issue.project) || project.is_descendant_of?(issue.project)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -136,6 +136,7 @@ class Repository < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
@committers = nil
|
@committers = nil
|
||||||
|
@found_committer_users = nil
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
@ -146,16 +147,22 @@ class Repository < ActiveRecord::Base
|
|||||||
# It will return nil if the committer is not yet mapped and if no User
|
# It will return nil if the committer is not yet mapped and if no User
|
||||||
# with the same username or email was found
|
# with the same username or email was found
|
||||||
def find_committer_user(committer)
|
def find_committer_user(committer)
|
||||||
if committer
|
unless committer.blank?
|
||||||
|
@found_committer_users ||= {}
|
||||||
|
return @found_committer_users[committer] if @found_committer_users.has_key?(committer)
|
||||||
|
|
||||||
|
user = nil
|
||||||
c = changesets.find(:first, :conditions => {:committer => committer}, :include => :user)
|
c = changesets.find(:first, :conditions => {:committer => committer}, :include => :user)
|
||||||
if c && c.user
|
if c && c.user
|
||||||
c.user
|
user = c.user
|
||||||
elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/
|
elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/
|
||||||
username, email = $1.strip, $3
|
username, email = $1.strip, $3
|
||||||
u = User.find_by_login(username)
|
u = User.find_by_login(username)
|
||||||
u ||= User.find_by_mail(email) unless email.blank?
|
u ||= User.find_by_mail(email) unless email.blank?
|
||||||
u
|
user = u
|
||||||
end
|
end
|
||||||
|
@found_committer_users[committer] = user
|
||||||
|
user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -286,8 +286,8 @@ module Redmine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def save(repo)
|
def save(repo)
|
||||||
if repo.changesets.find_by_scmid(scmid.to_s).nil?
|
Changeset.transaction do
|
||||||
changeset = Changeset.create!(
|
changeset = Changeset.new(
|
||||||
:repository => repo,
|
:repository => repo,
|
||||||
:revision => identifier,
|
:revision => identifier,
|
||||||
:scmid => scmid,
|
:scmid => scmid,
|
||||||
@ -295,8 +295,9 @@ module Redmine
|
|||||||
:committed_on => time,
|
:committed_on => time,
|
||||||
:comments => message)
|
:comments => message)
|
||||||
|
|
||||||
|
if changeset.save
|
||||||
paths.each do |file|
|
paths.each do |file|
|
||||||
Change.create!(
|
Change.create(
|
||||||
:changeset => changeset,
|
:changeset => changeset,
|
||||||
:action => file[:action],
|
:action => file[:action],
|
||||||
:path => file[:path])
|
:path => file[:path])
|
||||||
@ -304,6 +305,7 @@ module Redmine
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Annotate
|
class Annotate
|
||||||
attr_reader :lines, :revisions
|
attr_reader :lines, :revisions
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user