From 87f38fce3c4cb8ea7fdcf19b311376633c917871 Mon Sep 17 00:00:00 2001 From: Josh Hagins Date: Thu, 30 Jul 2015 16:34:31 -0400 Subject: [PATCH] ProtectedBranches: log pushed_refs in debug mode --- lib/overcommit/hook/pre_push/protected_branches.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/overcommit/hook/pre_push/protected_branches.rb b/lib/overcommit/hook/pre_push/protected_branches.rb index 93f77064..9575f63c 100644 --- a/lib/overcommit/hook/pre_push/protected_branches.rb +++ b/lib/overcommit/hook/pre_push/protected_branches.rb @@ -2,6 +2,7 @@ module Overcommit::Hook::PrePush # Prevents destructive updates to specified branches. class ProtectedBranches < Base def run + log_pushed_refs return :pass unless illegal_pushes.any? messages = illegal_pushes.map do |pushed_ref| @@ -13,6 +14,15 @@ def run private + def log_pushed_refs + log_msg = "\nPushed refs:\n\t#{pushed_refs_str}" + Overcommit::Utils.log.debug(log_msg) + end + + def pushed_refs_str + pushed_refs.map(&:to_s).join("\t\n") + end + def branches @branches ||= config['branches'] end