[Sprint 8] perf: Add early git check to git-flow branch-check.sh #322

Closed
opened 2026-01-29 22:02:58 +00:00 by lmiranda · 0 comments
Owner

Summary

Add early exit to branch-check.sh for non-git commands to avoid unnecessary JSON parsing.

Implementation: Change V5.5.0 (Sprint 8)

Problem

The hook currently:

  1. Reads stdin into $INPUT
  2. Parses JSON with grep/sed
  3. Checks if git command
  4. Exits if not

This happens on EVERY Bash command, even ls or npm install.

Solution

Add early check right after reading stdin:

INPUT=$(cat)

# Quick check - exit immediately if not a git command
if ! echo "$INPUT" | grep -q '"command".*git'; then
    exit 0
fi

Acceptance Criteria

  • Hook exits immediately for non-git commands
  • Branch validation still works for git checkout -b, git switch -c, git branch
  • No regression in existing functionality

Files to Modify

  • plugins/git-flow/hooks/branch-check.sh (add early check after line 7)

Milestone: Sprint 8 - Hook Efficiency Quick Wins

## Summary Add early exit to `branch-check.sh` for non-git commands to avoid unnecessary JSON parsing. **Implementation:** [Change V5.5.0 (Sprint 8)](https://gitea.hotserv.cloud/personal-projects/leo-claude-mktplace/wiki/Change-V5.5.0%3A-Hook-Efficiency-Quick-Wins-%28Sprint-8-Implementation%29) ## Problem The hook currently: 1. Reads stdin into $INPUT 2. Parses JSON with grep/sed 3. Checks if git command 4. Exits if not This happens on EVERY Bash command, even `ls` or `npm install`. ## Solution Add early check right after reading stdin: ```bash INPUT=$(cat) # Quick check - exit immediately if not a git command if ! echo "$INPUT" | grep -q '"command".*git'; then exit 0 fi ``` ## Acceptance Criteria - [ ] Hook exits immediately for non-git commands - [ ] Branch validation still works for `git checkout -b`, `git switch -c`, `git branch` - [ ] No regression in existing functionality ## Files to Modify - `plugins/git-flow/hooks/branch-check.sh` (add early check after line 7) **Milestone:** Sprint 8 - Hook Efficiency Quick Wins
lmiranda added the Type/RefactorComplexity/SimplePriority/MediumEffort/XS labels 2026-01-29 22:02:58 +00:00
lmiranda added this to the Sprint 8 - Hook Efficiency Quick Wins milestone 2026-01-30 18:14:01 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: personal-projects/leo-claude-mktplace#322