From 75f03b782f2d39dd1bded0a91d79fd191bc13136 Mon Sep 17 00:00:00 2001 From: Ismar Date: Tue, 13 Jan 2026 01:41:32 +0100 Subject: [PATCH] fix: pass hookArgs to runPrePushHook for chained hook support (#1043) Fixes #1041 The pre-push hook was not passing arguments to chained hooks, causing them to fail. This change: 1. Changes runPrePushHook() to accept args []string parameter 2. Passes args to runChainedHook() instead of nil 3. Updates call site to pass hookArgs 4. Renames local 'args' to 'statusArgs' to avoid variable shadowing Co-authored-by: Ismar Iljazovic --- cmd/bd/hooks.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/bd/hooks.go b/cmd/bd/hooks.go index 656d0552..83e201be 100644 --- a/cmd/bd/hooks.go +++ b/cmd/bd/hooks.go @@ -593,9 +593,9 @@ func runPostMergeHook() int { // runPrePushHook prevents pushing stale JSONL. // Returns 0 to allow push, non-zero to block. -func runPrePushHook() int { +func runPrePushHook(args []string) int { // Run chained hook first (if exists) - if exitCode := runChainedHook("pre-push", nil); exitCode != 0 { + if exitCode := runChainedHook("pre-push", args); exitCode != 0 { return exitCode } @@ -640,9 +640,9 @@ func runPrePushHook() int { } // Check for uncommitted changes using git status - args := append([]string{"status", "--porcelain", "--"}, files...) - // #nosec G204 - args built from hardcoded list and git subcommands - statusCmd := exec.Command("git", args...) + statusArgs := append([]string{"status", "--porcelain", "--"}, files...) + // #nosec G204 - statusArgs built from hardcoded list and git subcommands + statusCmd := exec.Command("git", statusArgs...) output, _ := statusCmd.Output() if len(output) > 0 { fmt.Fprintln(os.Stderr, "❌ Error: Uncommitted changes detected") @@ -1114,7 +1114,7 @@ installed bd version - upgrading bd automatically updates hook behavior.`, case "post-merge": exitCode = runPostMergeHook() case "pre-push": - exitCode = runPrePushHook() + exitCode = runPrePushHook(hookArgs) case "post-checkout": exitCode = runPostCheckoutHook(hookArgs) case "prepare-commit-msg":