fix: check merge success before firing /update-docs requirement #159
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/claude-custom!159
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "134-fix-post-merge-hook"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The
remind-update-docs.shPostToolUse hook fired unconditionally after everymcp__forgejo__merge_approved_prcall, including failed merges (405, 409). This told agents to run/update-docsfor merges that never happened -- observed 3 consecutive false fires during PR #124.Changes
hooks/remind-update-docs.sh-- Readtool_response.mergedfrom stdin before deciding. Failed merges now emit a failure notice instead of the blocking/update-docsrequirement. Matches the guard pattern already used byboard-item-on-merge.shandpost-mcp-merge-rebase.sh.Test Plan
{"tool_response": {"error": true, "status_code": 405}}) -- emits failure notice, no/update-docsblock{"tool_response": {"merged": true}}) -- emits blocking/update-docsrequirement as before{}) -- emits failure notice (safe default)Review Checklist
Related
Review -- PASS
Files reviewed:
hooks/remind-update-docs.sh(18 additions, 0 deletions)Findings: None.
jq -e '.tool_response.merged // false'piped togrep -q 'true') is identical to the proven pattern inboard-item-on-merge.shandpost-mcp-merge-rebase.sh. Consistent across all three PostToolUse merge hooks.INPUT=$(cat)reads stdin once; success-pathjq -nuses null input. No stdin consumption issue.tool_response,merged: false, error responses) all fall to failure branch. Safe default.Verdict: Approved. Clean single-file fix, well-tested.
PR #159 Review
DOMAIN REVIEW
Tech stack: Bash / jq hooks for the Claude Code PostToolUse hook system.
The change adds a merge-success guard to
hooks/remind-update-docs.sh. This hook was the only one of threemcp__forgejo__merge_approved_prPostToolUse hooks that fired unconditionally -- bothboard-item-on-merge.sh(line 36) andpost-mcp-merge-rebase.sh(line 12) already guard on.tool_response.merged. The PR closes that gap.Correctness: The guard logic is identical to the established pattern:
jq -eexits non-zero when the expression evaluates tofalseornull.// falseprovides a safe default when the key is missing entirely.grep -q 'true'is the secondary check.2>/dev/nullsuppresses jq errors on malformed input.This correctly handles all three failure modes documented in the PR body: HTTP 405 (merge blocked), HTTP 409 (conflict), and empty/missing response.
Failure path: Emits a structured
hookSpecificOutputJSON notice telling the agent the merge failed and not to run/update-docs. This is the right behavior -- it gives the agent actionable context without issuing a false blocking requirement.Success path: Falls through to the existing
jq -nblock that emits the BLOCKING REQUIREMENT. No change to existing behavior on successful merges.stdin handling: The new
INPUT=$(cat)is consistent with all other hooks in this repo. Claude Code provides each hook its own stdin copy (verified by the existing pattern across 29+ hooks in the repo).Hook ordering in settings.json (lines 211-226):
post-mcp-merge-rebase.shfires first, thenremind-update-docs.sh, thenboard-item-on-merge.sh. All three now guard on.tool_response.merged. Order is fine -- no dependencies between them.BLOCKERS
None.
NITS
additionalContextstring is generic: "Merge was not successful." The sibling hooks (board-item-on-merge.sh,post-mcp-merge-rebase.sh) exit silently on failure (no output). This hook emits a notice instead, which is arguably better for agent awareness, but the inconsistency is worth noting. Not blocking.SOP COMPLIANCE
134-fix-post-merge-hookreferences issue #134PROCESS OBSERVATIONS
This fix addresses a real production incident (3 consecutive false fires during PR #124 as documented in the issue). The change failure risk is very low -- it only adds a guard before existing logic, with no modifications to the success path. The pattern is battle-tested in two sibling hooks.
VERDICT: APPROVED