redmine: Make changeset keywords work with OS# annotation

In Osmocom we annotate osmocom issues as OS#1234 and not just as #1234,
in order to distinguish them from redmine or coverity issues.

Change-Id: I04a97434433a022f47a759a8219458e8772ae71e
Related: OS#5005, OS#3291
This commit is contained in:
Harald Welte 2021-02-10 15:38:10 +00:00 committed by Harald Welte
parent 60f4d39500
commit 57b6011e28
2 changed files with 21 additions and 0 deletions

View File

@ -11,3 +11,6 @@ RUN apt-get update && \
# no longer needed after ruby-openid-2.9.2 is used # no longer needed after ruby-openid-2.9.2 is used
#ADD hmac.diff /tmp/hmac.diff #ADD hmac.diff /tmp/hmac.diff
#RUN cd / && patch -p0 < /tmp/hmac.diff #RUN cd / && patch -p0 < /tmp/hmac.diff
ADD commitlog-references-oshash.diff /tmp/commitlog-references-oshash.diff
RUN cd /usr/src/redmine && patch -p1 < /tmp/commitlog-references-oshash.diff

View File

@ -0,0 +1,18 @@
diff --git a/app/models/changeset.rb b/app/models/changeset.rb
index 4256f0589..b5ef7b298 100644
--- a/app/models/changeset.rb
+++ b/app/models/changeset.rb
@@ -126,11 +126,11 @@ 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:]+)?(OS#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|\s|<|$)/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(/OS#(\d+)(\s+@#{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