From c79555eb5a0ddf99d53967e9f2631ff307338521 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 31 May 2021 12:49:40 +0200 Subject: webhook: include target ref for pull/merge requests Also add a TODO about a possible event-based output filter. --- data/rbot/plugins/webhook.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'data') diff --git a/data/rbot/plugins/webhook.rb b/data/rbot/plugins/webhook.rb index 6e8acb92..cf93d9a7 100644 --- a/data/rbot/plugins/webhook.rb +++ b/data/rbot/plugins/webhook.rb @@ -13,6 +13,15 @@ # TODO for the repo matchers in the built-in filters we might want to support # both the whole user/repo or just the repo name +# TODO specialized output filter by event/event_key, with some kind of automatic selection +# e.g. if :default_pull_request exists, then it's automatically used if :event => "pull_request" +# and :default is the current output filter. +# The big question is what we should fallback to if the specific filter doesn't exist.. +# +# If :custom exists, :default_pull_request exists and :custom_pull_request does not, +# should we fall back to :custom or to :default_pull_request? + + require 'json' class WebHookPlugin < Plugin @@ -211,6 +220,8 @@ class WebHookPlugin < Plugin :link => link } + stream_hash[:ref] ||= json[:base][:ref] if json[:base] + num = json[:number] || obj[:number] rescue nil stream_hash[:number] = '%{object} #%{num}' % { :num => num, :object => event_key.to_s.gsub('_', ' ') } if num num = json[:size] || json[:commits].size rescue nil @@ -279,6 +290,8 @@ class WebHookPlugin < Plugin :text => obj ? (obj[:note] || obj[:description]) : nil } + stream_hash[:ref] ||= obj[:target_branch] if obj + num = notable ? (notable[:iid] || notable[:id]) : obj ? obj[:iid] || obj[:id] : nil stream_hash[:number] = '%{object} #%{num}' % { :num => num, :object => (obj[:noteable_type] || event).to_s.gsub('_', ' ') } if num num = json[:total_commits_count] -- cgit v1.2.3