scm: code clean up app/models/changeset.rb.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5372 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
c12453ec4e
commit
b9ce061319
|
@ -74,21 +74,22 @@ class Changeset < ActiveRecord::Base
|
||||||
def project
|
def project
|
||||||
repository.project
|
repository.project
|
||||||
end
|
end
|
||||||
|
|
||||||
def author
|
def author
|
||||||
user || committer.to_s.split('<').first
|
user || committer.to_s.split('<').first
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_create
|
def before_create
|
||||||
self.committer = self.class.to_utf8(self.committer, repository.repo_log_encoding)
|
self.committer = self.class.to_utf8(self.committer, repository.repo_log_encoding)
|
||||||
self.comments = self.class.normalize_comments(self.comments, repository.repo_log_encoding)
|
self.comments = self.class.normalize_comments(
|
||||||
|
self.comments, repository.repo_log_encoding)
|
||||||
self.user = repository.find_committer_user(self.committer)
|
self.user = repository.find_committer_user(self.committer)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_create
|
def after_create
|
||||||
scan_comment_for_issue_ids
|
scan_comment_for_issue_ids
|
||||||
end
|
end
|
||||||
|
|
||||||
TIMELOG_RE = /
|
TIMELOG_RE = /
|
||||||
(
|
(
|
||||||
((\d+)(h|hours?))((\d+)(m|min)?)?
|
((\d+)(h|hours?))((\d+)(m|min)?)?
|
||||||
|
@ -174,7 +175,9 @@ class Changeset < ActiveRecord::Base
|
||||||
return nil if id.blank?
|
return nil if id.blank?
|
||||||
issue = Issue.find_by_id(id.to_i, :include => :project)
|
issue = Issue.find_by_id(id.to_i, :include => :project)
|
||||||
if issue
|
if issue
|
||||||
unless issue.project && (project == issue.project || project.is_ancestor_of?(issue.project) || project.is_descendant_of?(issue.project))
|
unless issue.project &&
|
||||||
|
(project == issue.project || project.is_ancestor_of?(issue.project) ||
|
||||||
|
project.is_descendant_of?(issue.project))
|
||||||
issue = nil
|
issue = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -205,14 +208,15 @@ class Changeset < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
issue
|
issue
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_time(issue, hours)
|
def log_time(issue, hours)
|
||||||
time_entry = TimeEntry.new(
|
time_entry = TimeEntry.new(
|
||||||
:user => user,
|
:user => user,
|
||||||
:hours => hours,
|
:hours => hours,
|
||||||
:issue => issue,
|
:issue => issue,
|
||||||
:spent_on => commit_date,
|
:spent_on => commit_date,
|
||||||
:comments => l(:text_time_logged_by_changeset, :value => text_tag, :locale => Setting.default_language)
|
:comments => l(:text_time_logged_by_changeset, :value => text_tag,
|
||||||
|
:locale => Setting.default_language)
|
||||||
)
|
)
|
||||||
time_entry.activity = log_time_activity unless log_time_activity.nil?
|
time_entry.activity = log_time_activity unless log_time_activity.nil?
|
||||||
|
|
||||||
|
@ -221,13 +225,13 @@ class Changeset < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
time_entry
|
time_entry
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_time_activity
|
def log_time_activity
|
||||||
if Setting.commit_logtime_activity_id.to_i > 0
|
if Setting.commit_logtime_activity_id.to_i > 0
|
||||||
TimeEntryActivity.find_by_id(Setting.commit_logtime_activity_id.to_i)
|
TimeEntryActivity.find_by_id(Setting.commit_logtime_activity_id.to_i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def split_comments
|
def split_comments
|
||||||
comments =~ /\A(.+?)\r?\n(.*)$/m
|
comments =~ /\A(.+?)\r?\n(.*)$/m
|
||||||
@short_comments = $1 || comments
|
@short_comments = $1 || comments
|
||||||
|
|
Loading…
Reference in New Issue