summaryrefslogtreecommitdiff
path: root/lib/oxidized/hook
diff options
context:
space:
mode:
authorAdam Smith <zero1three@gmail.com>2018-01-25 14:11:07 -0800
committerNeil Lathwood <neil@lathwood.co.uk>2018-01-25 22:11:07 +0000
commitd6456bf490e71c7e3f453497641ff5c7952a018e (patch)
tree054701a00bf0f430391de1033371d7d07861ec30 /lib/oxidized/hook
parent4e59878052f0668f4dde2282e86882626936f6b4 (diff)
fix: Don't post diff to Slack if there are no diffs (#1151)
Diffstat (limited to 'lib/oxidized/hook')
-rw-r--r--lib/oxidized/hook/slackdiff.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/oxidized/hook/slackdiff.rb b/lib/oxidized/hook/slackdiff.rb
index 728e5a7..7cd4465 100644
--- a/lib/oxidized/hook/slackdiff.rb
+++ b/lib/oxidized/hook/slackdiff.rb
@@ -30,14 +30,16 @@ class SlackDiff < Oxidized::Hook
if diffenable == true
gitoutput = ctx.node.output.new
diff = gitoutput.get_diff ctx.node, ctx.node.group, ctx.commitref, nil
- title = "#{ctx.node.name.to_s} #{ctx.node.group.to_s} #{ctx.node.model.class.name.to_s.downcase}"
- log "Posting diff as snippet to #{cfg.channel}"
- client.files_upload(channels: cfg.channel, as_user: true,
- content: diff[:patch].lines.to_a[4..-1].join,
- filetype: "diff",
- title: title,
- filename: "change"
- )
+ unless diff == "no diffs"
+ title = "#{ctx.node.name.to_s} #{ctx.node.group.to_s} #{ctx.node.model.class.name.to_s.downcase}"
+ log "Posting diff as snippet to #{cfg.channel}"
+ client.files_upload(channels: cfg.channel, as_user: true,
+ content: diff[:patch].lines.to_a[4..-1].join,
+ filetype: "diff",
+ title: title,
+ filename: "change"
+ )
+ end
end
# message custom formatted - optional
if cfg.has_key?('message') == true