[Sprint 8] perf: Add early git check to git-flow commit-msg-check.sh #323

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

Summary

Add early exit to commit-msg-check.sh for non-git commands to avoid spawning Python.

Implementation: Change V5.5.0 (Sprint 8)

Problem

The hook currently:

  1. Reads stdin
  2. Spawns Python to parse JSON (50-100ms overhead)
  3. Checks if git commit -m command
  4. Exits if not

Python startup is expensive. This happens on EVERY Bash command.

Solution

Add early check BEFORE Python:

INPUT=$(cat)

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

Acceptance Criteria

  • Hook exits immediately for non-git-commit commands
  • Commit message validation still works for git commit -m
  • No regression in existing functionality
  • Python only spawned when actually needed

Files to Modify

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

Milestone: Sprint 8 - Hook Efficiency Quick Wins

## Summary Add early exit to `commit-msg-check.sh` for non-git commands to avoid spawning Python. **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 2. **Spawns Python** to parse JSON (50-100ms overhead) 3. Checks if `git commit -m` command 4. Exits if not Python startup is expensive. This happens on EVERY Bash command. ## Solution Add early check BEFORE Python: ```bash INPUT=$(cat) # Quick check - exit immediately if not a git commit command if ! echo "$INPUT" | grep -q '"command".*git.*commit'; then exit 0 fi ``` ## Acceptance Criteria - [ ] Hook exits immediately for non-git-commit commands - [ ] Commit message validation still works for `git commit -m` - [ ] No regression in existing functionality - [ ] Python only spawned when actually needed ## Files to Modify - `plugins/git-flow/hooks/commit-msg-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:59 +00:00
lmiranda added this to the Sprint 8 - Hook Efficiency Quick Wins milestone 2026-01-30 18:14:02 +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#323