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 <ismar@gmail.com>
This commit is contained in:
@@ -593,9 +593,9 @@ func runPostMergeHook() int {
|
|||||||
|
|
||||||
// runPrePushHook prevents pushing stale JSONL.
|
// runPrePushHook prevents pushing stale JSONL.
|
||||||
// Returns 0 to allow push, non-zero to block.
|
// Returns 0 to allow push, non-zero to block.
|
||||||
func runPrePushHook() int {
|
func runPrePushHook(args []string) int {
|
||||||
// Run chained hook first (if exists)
|
// Run chained hook first (if exists)
|
||||||
if exitCode := runChainedHook("pre-push", nil); exitCode != 0 {
|
if exitCode := runChainedHook("pre-push", args); exitCode != 0 {
|
||||||
return exitCode
|
return exitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,9 +640,9 @@ func runPrePushHook() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for uncommitted changes using git status
|
// Check for uncommitted changes using git status
|
||||||
args := append([]string{"status", "--porcelain", "--"}, files...)
|
statusArgs := append([]string{"status", "--porcelain", "--"}, files...)
|
||||||
// #nosec G204 - args built from hardcoded list and git subcommands
|
// #nosec G204 - statusArgs built from hardcoded list and git subcommands
|
||||||
statusCmd := exec.Command("git", args...)
|
statusCmd := exec.Command("git", statusArgs...)
|
||||||
output, _ := statusCmd.Output()
|
output, _ := statusCmd.Output()
|
||||||
if len(output) > 0 {
|
if len(output) > 0 {
|
||||||
fmt.Fprintln(os.Stderr, "❌ Error: Uncommitted changes detected")
|
fmt.Fprintln(os.Stderr, "❌ Error: Uncommitted changes detected")
|
||||||
@@ -1114,7 +1114,7 @@ installed bd version - upgrading bd automatically updates hook behavior.`,
|
|||||||
case "post-merge":
|
case "post-merge":
|
||||||
exitCode = runPostMergeHook()
|
exitCode = runPostMergeHook()
|
||||||
case "pre-push":
|
case "pre-push":
|
||||||
exitCode = runPrePushHook()
|
exitCode = runPrePushHook(hookArgs)
|
||||||
case "post-checkout":
|
case "post-checkout":
|
||||||
exitCode = runPostCheckoutHook(hookArgs)
|
exitCode = runPostCheckoutHook(hookArgs)
|
||||||
case "prepare-commit-msg":
|
case "prepare-commit-msg":
|
||||||
|
|||||||
Reference in New Issue
Block a user