changeset.diff

Felix Tiede, 2013-11-26 00:39

Download (2.02 KB)

View differences:

app/models/changeset.rb 2013-11-26 00:34:25.000000000 +0100
111 111
    (\d+([\.,]\d+)?)h?
112 112
    )
113 113
    /x
114
  DONERATIO_RE = /
115
    (
116
    (100)
117
    |
118
    (\d0)
119
    )
120
    /x
114 121

  
115 122
  def scan_comment_for_issue_ids
116 123
    return if comments.blank?
......
124 131

  
125 132
    referenced_issues = []
126 133

  
127
    comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|\s|<|$)/i) do |match|
134
    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|
128 135
      action, refs = match[2], match[3]
129 136
      next unless action.present? || ref_keywords_any
130 137

  
131
      refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m|
132
        issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2]
138
      refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?(\s+#{DONERATIO_RE}%)?/).each do |m|
139
        issue, hours, ratio = find_referenced_issue_by_id(m[0].to_i), m[2], m[17]
133 140
        if issue
134 141
          referenced_issues << issue
135 142
          fix_issue(issue) if fix_keywords.include?(action.to_s.downcase)
136 143
          log_time(issue, hours) if hours && Setting.commit_logtime_enabled?
144
          done_ratio(issue, ratio) if ratio
137 145
        end
138 146
      end
139 147
    end
......
258 266
    end
259 267
  end
260 268

  
269
  def done_ratio(issue, ratio)
270
    issue.reload
271
    journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, text_tag(issue.project)))
272
    issue.done_ratio = ratio.to_i
273
    unless issue.save
274
      logger.warn("Issue ##{issue.id} could not be saved by changeset #{id}: #{issue.errors.full_messages}") if logger
275
    end
276
    issue
277
  end
278

  
261 279
  def split_comments
262 280
    comments =~ /\A(.+?)\r?\n(.*)$/m
263 281
    @short_comments = $1 || comments