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