--- a/app/models/changeset.rb 2013-11-06 08:41:46.000000000 +0100 +++ b/app/models/changeset.rb 2013-11-26 00:34:25.000000000 +0100 @@ -111,6 +111,13 @@ class Changeset < ActiveRecord::Base (\d+([\.,]\d+)?)h? ) /x + DONERATIO_RE = / + ( + (100) + | + (\d0) + ) + /x def scan_comment_for_issue_ids return if comments.blank? @@ -124,16 +131,17 @@ class Changeset < ActiveRecord::Base referenced_issues = [] - comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|\s|<|$)/i) do |match| + comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+(\s+@#{TIMELOG_RE})?(\s+#{DONERATIO_RE}%)?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?(\s+#{DONERATIO_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] + refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?(\s+#{DONERATIO_RE}%)?/).each do |m| + issue, hours, ratio = find_referenced_issue_by_id(m[0].to_i), m[2], 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? + done_ratio(issue, ratio) if ratio end end end @@ -258,6 +266,16 @@ class Changeset < ActiveRecord::Base end end + def done_ratio(issue, ratio) + issue.reload + journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, text_tag(issue.project))) + issue.done_ratio = ratio.to_i + unless issue.save + logger.warn("Issue ##{issue.id} could not be saved by changeset #{id}: #{issue.errors.full_messages}") if logger + end + issue + end + def split_comments comments =~ /\A(.+?)\r?\n(.*)$/m @short_comments = $1 || comments