@@ -1,16 +1,16 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 |
# Copyright (C) 2006-201 |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 |
# |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 |
# |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
@@ -27,23 +27,23 class Changeset < ActiveRecord::Base | |||||
27 | :description => :long_comments, |
|
27 | :description => :long_comments, | |
28 | :datetime => :committed_on, |
|
28 | :datetime => :committed_on, | |
29 | :url => Proc.new {|o| {:controller => 'repositories', :action => 'revision', :id => o.repository.project, :rev => o.identifier}} |
|
29 | :url => Proc.new {|o| {:controller => 'repositories', :action => 'revision', :id => o.repository.project, :rev => o.identifier}} | |
30 |
|
30 | |||
31 | acts_as_searchable :columns => 'comments', |
|
31 | acts_as_searchable :columns => 'comments', | |
32 | :include => {:repository => :project}, |
|
32 | :include => {:repository => :project}, | |
33 | :project_key => "#{Repository.table_name}.project_id", |
|
33 | :project_key => "#{Repository.table_name}.project_id", | |
34 | :date_column => 'committed_on' |
|
34 | :date_column => 'committed_on' | |
35 |
|
35 | |||
36 | acts_as_activity_provider :timestamp => "#{table_name}.committed_on", |
|
36 | acts_as_activity_provider :timestamp => "#{table_name}.committed_on", | |
37 | :author_key => :user_id, |
|
37 | :author_key => :user_id, | |
38 | :find_options => {:include => [:user, {:repository => :project}]} |
|
38 | :find_options => {:include => [:user, {:repository => :project}]} | |
39 |
|
39 | |||
40 | validates_presence_of :repository_id, :revision, :committed_on, :commit_date |
|
40 | validates_presence_of :repository_id, :revision, :committed_on, :commit_date | |
41 | validates_uniqueness_of :revision, :scope => :repository_id |
|
41 | validates_uniqueness_of :revision, :scope => :repository_id | |
42 | validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true |
|
42 | validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true | |
43 |
|
43 | |||
44 | named_scope :visible, lambda {|*args| { :include => {:repository => :project}, |
|
44 | named_scope :visible, lambda {|*args| { :include => {:repository => :project}, | |
45 | :conditions => Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args) } } |
|
45 | :conditions => Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args) } } | |
46 |
|
46 | |||
47 | def revision=(r) |
|
47 | def revision=(r) | |
48 | write_attribute :revision, (r.nil? ? nil : r.to_s) |
|
48 | write_attribute :revision, (r.nil? ? nil : r.to_s) | |
49 | end |
|
49 | end | |
@@ -70,7 +70,7 class Changeset < ActiveRecord::Base | |||||
70 | identifier |
|
70 | identifier | |
71 | end |
|
71 | end | |
72 | end |
|
72 | end | |
73 |
|
73 | |||
74 | def project |
|
74 | def project | |
75 | repository.project |
|
75 | repository.project | |
76 | end |
|
76 | end | |
@@ -101,7 +101,7 class Changeset < ActiveRecord::Base | |||||
101 | (\d+([\.,]\d+)?)h? |
|
101 | (\d+([\.,]\d+)?)h? | |
102 | ) |
|
102 | ) | |
103 | /x |
|
103 | /x | |
104 |
|
104 | |||
105 | def scan_comment_for_issue_ids |
|
105 | def scan_comment_for_issue_ids | |
106 | return if comments.blank? |
|
106 | return if comments.blank? | |
107 | # keywords used to reference issues |
|
107 | # keywords used to reference issues | |
@@ -109,15 +109,15 class Changeset < ActiveRecord::Base | |||||
109 | ref_keywords_any = ref_keywords.delete('*') |
|
109 | ref_keywords_any = ref_keywords.delete('*') | |
110 | # keywords used to fix issues |
|
110 | # keywords used to fix issues | |
111 | fix_keywords = Setting.commit_fix_keywords.downcase.split(",").collect(&:strip) |
|
111 | fix_keywords = Setting.commit_fix_keywords.downcase.split(",").collect(&:strip) | |
112 |
|
112 | |||
113 | kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|") |
|
113 | kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|") | |
114 |
|
114 | |||
115 | referenced_issues = [] |
|
115 | referenced_issues = [] | |
116 |
|
116 | |||
117 | comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|\s|<|$)/i) do |match| |
|
117 | comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|\s|<|$)/i) do |match| | |
118 | action, refs = match[2], match[3] |
|
118 | action, refs = match[2], match[3] | |
119 | next unless action.present? || ref_keywords_any |
|
119 | next unless action.present? || ref_keywords_any | |
120 |
|
120 | |||
121 | refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m| |
|
121 | refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m| | |
122 | issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2] |
|
122 | issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2] | |
123 | if issue |
|
123 | if issue | |
@@ -127,15 +127,15 class Changeset < ActiveRecord::Base | |||||
127 | end |
|
127 | end | |
128 | end |
|
128 | end | |
129 | end |
|
129 | end | |
130 |
|
130 | |||
131 | referenced_issues.uniq! |
|
131 | referenced_issues.uniq! | |
132 | self.issues = referenced_issues unless referenced_issues.empty? |
|
132 | self.issues = referenced_issues unless referenced_issues.empty? | |
133 | end |
|
133 | end | |
134 |
|
134 | |||
135 | def short_comments |
|
135 | def short_comments | |
136 | @short_comments || split_comments.first |
|
136 | @short_comments || split_comments.first | |
137 | end |
|
137 | end | |
138 |
|
138 | |||
139 | def long_comments |
|
139 | def long_comments | |
140 | @long_comments || split_comments.last |
|
140 | @long_comments || split_comments.last | |
141 | end |
|
141 | end | |
@@ -189,19 +189,19 class Changeset < ActiveRecord::Base | |||||
189 | end |
|
189 | end | |
190 | issue |
|
190 | issue | |
191 | end |
|
191 | end | |
192 |
|
192 | |||
193 | def fix_issue(issue) |
|
193 | def fix_issue(issue) | |
194 | status = IssueStatus.find_by_id(Setting.commit_fix_status_id.to_i) |
|
194 | status = IssueStatus.find_by_id(Setting.commit_fix_status_id.to_i) | |
195 | if status.nil? |
|
195 | if status.nil? | |
196 | logger.warn("No status macthes commit_fix_status_id setting (#{Setting.commit_fix_status_id})") if logger |
|
196 | logger.warn("No status macthes commit_fix_status_id setting (#{Setting.commit_fix_status_id})") if logger | |
197 | return issue |
|
197 | return issue | |
198 | end |
|
198 | end | |
199 |
|
199 | |||
200 | # the issue may have been updated by the closure of another one (eg. duplicate) |
|
200 | # the issue may have been updated by the closure of another one (eg. duplicate) | |
201 | issue.reload |
|
201 | issue.reload | |
202 | # don't change the status is the issue is closed |
|
202 | # don't change the status is the issue is closed | |
203 | return if issue.status && issue.status.is_closed? |
|
203 | return if issue.status && issue.status.is_closed? | |
204 |
|
204 | |||
205 | journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, text_tag)) |
|
205 | journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, text_tag)) | |
206 | issue.status = status |
|
206 | issue.status = status | |
207 | unless Setting.commit_fix_done_ratio.blank? |
|
207 | unless Setting.commit_fix_done_ratio.blank? | |
@@ -225,7 +225,7 class Changeset < ActiveRecord::Base | |||||
225 | :locale => Setting.default_language) |
|
225 | :locale => Setting.default_language) | |
226 | ) |
|
226 | ) | |
227 | time_entry.activity = log_time_activity unless log_time_activity.nil? |
|
227 | time_entry.activity = log_time_activity unless log_time_activity.nil? | |
228 |
|
228 | |||
229 | unless time_entry.save |
|
229 | unless time_entry.save | |
230 | logger.warn("TimeEntry could not be created by changeset #{id}: #{time_entry.errors.full_messages}") if logger |
|
230 | logger.warn("TimeEntry could not be created by changeset #{id}: #{time_entry.errors.full_messages}") if logger | |
231 | end |
|
231 | end |
General Comments 0
You need to be logged in to leave comments.
Login now