Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: handle before_/after_ prefixes in auto-commit message derivation
- Strip both before_ and after_ prefixes when deriving command name
  (fixes misleading 'Auto-commit after before_plan' messages)
- Include phase (before/after) in default commit messages
- Clarify README config example is an override, not default behavior
  • Loading branch information
mnriem committed Apr 7, 2026
commit 2f352cdf5c7ca935ee05c83c019d457c04c56768
1 change: 1 addition & 0 deletions extensions/git/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ branch_numbering: sequential
init_commit_message: "[Spec Kit] Initial commit"

# Auto-commit per command (all disabled by default)
# Example: enable auto-commit after specify
auto_commit:
default: false
after_specify:
Expand Down
9 changes: 5 additions & 4 deletions extensions/git/scripts/bash/auto-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,17 @@ if git diff --quiet HEAD 2>/dev/null && git diff --cached --quiet 2>/dev/null &&
fi

# Derive a human-readable command name from the event
# e.g., after_specify -> specify, after_plan -> plan
_command_name=$(echo "$EVENT_NAME" | sed 's/^after_//')
# e.g., after_specify -> specify, before_plan -> plan
_command_name=$(echo "$EVENT_NAME" | sed 's/^after_//' | sed 's/^before_//')
_phase=$(echo "$EVENT_NAME" | grep -q '^before_' && echo 'before' || echo 'after')

# Use custom message if configured, otherwise default
if [ -z "$_commit_msg" ]; then
_commit_msg="[Spec Kit] Auto-commit after ${_command_name}"
_commit_msg="[Spec Kit] Auto-commit ${_phase} ${_command_name}"
fi
Comment thread
mnriem marked this conversation as resolved.

# Stage and commit
_git_out=$(git add . 2>&1) || { echo "[specify] Error: git add failed: $_git_out" >&2; exit 1; }
_git_out=$(git commit -q -m "$_commit_msg" 2>&1) || { echo "[specify] Error: git commit failed: $_git_out" >&2; exit 1; }

echo "✓ Changes committed after ${_command_name}" >&2
echo "✓ Changes committed ${_phase} ${_command_name}" >&2
7 changes: 4 additions & 3 deletions extensions/git/scripts/powershell/auto-commit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,12 @@ if ($d1 -eq 0 -and $d2 -eq 0 -and -not $untracked) {
}

# Derive a human-readable command name from the event
$commandName = $EventName -replace '^after_', ''
$commandName = $EventName -replace '^after_', '' -replace '^before_', ''
$phase = if ($EventName -match '^before_') { 'before' } else { 'after' }

# Use custom message if configured, otherwise default
if (-not $commitMsg) {
$commitMsg = "[Spec Kit] Auto-commit after $commandName"
$commitMsg = "[Spec Kit] Auto-commit $phase $commandName"
}
Comment thread
mnriem marked this conversation as resolved.

# Stage and commit
Expand All @@ -145,4 +146,4 @@ try {
exit 1
}

Write-Host "✓ Changes committed after $commandName"
Write-Host "✓ Changes committed $phase $commandName"
Loading