--- changeset.rb 2012-08-14 14:48:06.802295605 -0400 +++ changet.rb.o 2012-08-14 14:49:02.294227825 -0400 @@ -1,3 +1,4 @@ + # Redmine - project management software # Copyright (C) 2006-2012 Jean-Philippe Lang # @@ -104,9 +105,9 @@ TIMELOG_RE = / ( - ((\d+)(h|hours?))((\d+)(m|min)?)? + ((\d+)(h|hours?))((\d+)(min|m)?)? | - ((\d+)(h|hours?|m|min)) + ((\d+)(h|hours?|min|m)) | (\d+):(\d+) | @@ -125,17 +126,18 @@ kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|") referenced_issues = [] + + comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+((\s+@#{TIMELOG_RE})?(\s+&(.*?)&)?)([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?(\s+&(.*?)&)?)*)(?=[[:punct:]]|\s|<|$)/i) do |match| - comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|\s|<|$)/i) do |match| - action, refs = match[2], match[3] - next unless action.present? || ref_keywords_any - - refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m| - issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2] - if issue + action, refs = match[2], match[3] + next unless action.present? || ref_keywords_any + refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})(\s+&(.*?)&)?/).each do |m| + issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2] + log_comment = m[17] + if issue referenced_issues << issue fix_issue(issue) if fix_keywords.include?(action.to_s.downcase) - log_time(issue, hours) if hours && Setting.commit_logtime_enabled? + log_time(issue, hours, log_comment) if hours && Setting.commit_logtime_enabled? end end end @@ -243,15 +245,19 @@ issue end - def log_time(issue, hours) - time_entry = TimeEntry.new( + def log_time(issue, hours, comment) + if comment.nil? + comment=l(:text_time_logged_by_changeset, :value => text_tag(issue.project),:locale => Setting.default_language) + else + comment+= " [" + text_tag(issue.project) +"]" + end + time_entry = TimeEntry.new( :user => user, :hours => hours, :issue => issue, :spent_on => commit_date, - :comments => l(:text_time_logged_by_changeset, :value => text_tag(issue.project), - :locale => Setting.default_language) - ) + :comments => comment + ) time_entry.activity = log_time_activity unless log_time_activity.nil? unless time_entry.save