Skip to content

Commit d801e79

Browse files
committed
refactor: extract prepare-commit-msg hook to separate script file
- Move commitment hook logic from inline lefthook.yml to dedicated .lefthook/prepare-commit-msg/commitment.sh - Preserve hook behavior: only run for regular commits (check if $2 is empty) - Simplify lefthook.yml configuration using scripts runner instead of inline command 🤖 Generated with Claude via commitment
1 parent 82bfb47 commit d801e79

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
# Commitment hook for prepare-commit-msg
3+
# Arguments: $1 = commit message file, $2 = commit source (empty for regular commits)
4+
5+
# Only run for regular commits (no commit source means git commit without -m)
6+
if [ -z "$2" ]; then
7+
./dist/cli.js --message-only > "$1"
8+
fi

lefthook.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ prepare-commit-msg:
1414
skip:
1515
- merge
1616
- rebase
17-
commands:
18-
commitment:
19-
# Only run for regular commits (not merge, squash, or when message specified)
20-
# {1} is the commit message file, {2} is the commit source
21-
run: '[ -z "{2}" ] && ./dist/cli.js --message-only > {1} || true'
17+
scripts:
18+
"commitment.sh":
19+
runner: sh

0 commit comments

Comments
 (0)