Defect #28322 ยป 0001-Don-t-match-commit-references-across-new-lines.patch
| app/models/changeset.rb | ||
|---|---|---|
|
referenced_issues = []
|
||
|
comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|\s|<|$)/i) do |match|
|
||
|
comments.scan(/([[[:blank:]]\(\[,-]|^)((#{kw_regexp})[[[:blank:]]:]+)?(#\d+([[:blank:]]+@#{TIMELOG_RE})?([[[:blank:]],;&]+#\d+([[:blank:]]+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|[[:blank:]]|<|$)/i) do |match|
|
||
|
action, refs = match[2].to_s.downcase, match[3]
|
||
|
next unless action.present? || ref_keywords_any
|
||
|
refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m|
|
||
|
refs.scan(/#(\d+)([[:blank:]]+@#{TIMELOG_RE})?/).each do |m|
|
||
|
issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2]
|
||
|
if issue && !issue_linked_to_same_commit?(issue)
|
||
|
referenced_issues << issue
|
||
| test/unit/changeset_test.rb | ||
|---|---|---|
|
assert_equal [1], c.issue_ids.sort
|
||
|
end
|
||
|
def test_ref_keywords_stop_at_newlines
|
||
|
ActionMailer::Base.deliveries.clear
|
||
|
Setting.commit_ref_keywords = '*'
|
||
|
Setting.commit_update_keywords = [{'keywords' => 'fixes', 'status_id' => '5'}]
|
||
|
c = Changeset.new(:repository => Project.find(1).repository,
|
||
|
:committed_on => Time.now,
|
||
|
:comments => "#1 some UI fixes\n#2 still work in progess",
|
||
|
:revision => '12345')
|
||
|
assert c.save
|
||
|
assert_equal [1, 2], c.issue_ids.sort
|
||
|
wip = Issue.find(2)
|
||
|
assert !wip.closed?
|
||
|
assert_empty ActionMailer::Base.deliveries
|
||
|
end
|
||
|
def test_ref_keywords_any_only
|
||
|
Setting.commit_ref_keywords = '*'
|
||
|
Setting.commit_update_keywords = ''
|
||