summaryrefslogtreecommitdiff
path: root/data/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2021-05-31 12:49:40 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2021-05-31 13:20:43 +0200
commitc79555eb5a0ddf99d53967e9f2631ff307338521 (patch)
tree1dca8025aabaf3e8da0a96c4ce0f151a1dcd0d88 /data/rbot
parente2874c9f8636ed2978eb72fc7a29acab909e7d7b (diff)
webhook: include target ref for pull/merge requests
Also add a TODO about a possible event-based output filter.
Diffstat (limited to 'data/rbot')
-rw-r--r--data/rbot/plugins/webhook.rb13
1 files changed, 13 insertions, 0 deletions
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]