From b7dd157b41e1c3a57c098a6a5402899784b2041f Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Fri, 18 Jun 2021 22:25:25 -0700 Subject: bugzilla: support bug aliases Closes: https://bugs.gentoo.org/356123 Signed-off-by: Robin H. Johnson --- bugzilla.rb | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/bugzilla.rb b/bugzilla.rb index d9af38f..a1f0e6a 100644 --- a/bugzilla.rb +++ b/bugzilla.rb @@ -533,13 +533,31 @@ class BugzillaPlugin < Plugin def listen(m) return if m.address? return unless lurk?(m) - return if m.message !~ /\bbug(?:[[:space:]]*)?#?([0-9]+)(?:(?:#c| comment #?)([0-9]+))?/i - bugno = $1 - comment = $2 || "" - bugno.gsub!(/^#/,'') - comment.gsub!(/^#c?/,'') - zilla = get_zilla(m) - m.reply zilla.summary(bugno, comment) + # bug 1234 + # bug 1234#c1234 + # bug 1234 comment 1234 + # bug 1234 comment #1234 + # bug #1234 + # bug #1234#c1234 + # bug #1234 comment 1234 + # bug #1234 comment #1234 + # bug #gcc + # bug #gcc#c1234 + # bug #gcc comment 1234 + # bug #gcc comment #1234 + # + # bug aliases can contain + # 0-9, a-z, A-Z + # and then every punctuation except "," + message_re = /\bbug(?:[[:space:]]*)(?:#?([0-9]+|#[-[:alnum:]~`!@#$%^&*()_+={}\]\[\\/|:;\'"<>.?]{3,40}))(?:(?:#c| comment #?)([0-9]+))?/i + message.scan(message_re).each do |bug_comment| + bugno = bug_comment[0] + comment = bug_comment[1] || "" + bugno.gsub!(/^#/,'') + comment.gsub!(/^#c?/,'') + zilla = get_zilla(m) + m.reply zilla.summary(bugno, comment) + end end # Function checking when a new channel is joined -- cgit v1.2.3-65-gdbad