feat(git-extension): add configurable Conventional Commit support (#3390)#3413
feat(git-extension): add configurable Conventional Commit support (#3390)#3413dhruv-15-03 wants to merge 3 commits into
Conversation
Adds a commit_style option (fixed | conventional) to the git extension's auto-commit config. When set to conventional, the speckit.git.commit hook instructs the agent to generate a Conventional Commit message from the diff and pass it to auto-commit.sh / auto-commit.ps1 as an explicit argument. If no message is supplied in conventional mode, the scripts fail loudly (stderr + exit 1) instead of silently falling back to the fixed message, but still short-circuit cleanly when there are no changes to commit. - extensions/git/config-template.yml, git-config.yml: new commit_style: fixed (default) / conventional option. - extensions/git/scripts/bash/auto-commit.sh: optional [generated_message] arg, commit_style parsing, conventional-mode enforcement. - extensions/git/scripts/powershell/auto-commit.ps1: mirrored PowerShell implementation. - extensions/git/commands/speckit.git.commit.md: documents commit message styles and updated execution/config guidance. - extensions/git/README.md: documents the new option. - tests/extensions/git/test_git_extension.py: regression tests for fixed default, conventional success, conventional missing-message failure, and no-changes short-circuit (bash + PowerShell). Fixes github#3390 Assisted-by: GitHub Copilot (model: claude-sonnet-5, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
/lgtm |
| # Top-level scalar key: commit_style (fixed | conventional) | ||
| foreach ($line in Get-Content $configFile) { | ||
| if ($line -match '^commit_style:\s*(.+)$') { | ||
| $styleVal = $matches[1].Trim() -replace '^["'']' -replace '["'']$' | ||
| if ($styleVal) { $commitStyle = $styleVal.ToLower() } | ||
| break | ||
| } | ||
| } |
| if [ -f "$_config_file" ]; then | ||
| # Top-level scalar key: commit_style (fixed | conventional) | ||
| _style_val=$(grep '^commit_style:' "$_config_file" 2>/dev/null | sed 's/^commit_style:[[:space:]]*//' | sed 's/^["'\'']//' | sed 's/["'\'']*$//' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]') | ||
| [ -n "$_style_val" ] && _commit_style="$_style_val" | ||
|
|
||
| # Parse the auto_commit section for this event. |
…e failure test Write-Warning output stream placement is not deterministic across pwsh versions/platforms (observed failing on macOS CI). Match the existing pattern used elsewhere in this file (e.g. test_not_a_repo_still_detected_with_autocrlf) by asserting against the combined stdout+stderr instead of stderr alone. Assisted-by: GitHub Copilot (model: claude-sonnet-5, autonomous)
|
Posted by GitHub Copilot (model: claude-sonnet-5) on behalf of @dhruv-15-03. Fixed the flaky macOS CI failure in |
| # Top-level scalar key: commit_style (fixed | conventional) | ||
| foreach ($line in Get-Content $configFile) { | ||
| if ($line -match '^commit_style:\s*(.+)$') { | ||
| $styleVal = $matches[1].Trim() -replace '^["'']' -replace '["'']$' |
| @pytest.mark.skipif(not HAS_PWSH, reason="pwsh not available") | ||
| class TestAutoCommitPowerShellCommitStyle: | ||
| """Tests for the `commit_style: conventional` option (issue #3390).""" |
| # Top-level scalar key: commit_style (fixed | conventional) | ||
| _style_val=$(grep '^commit_style:' "$_config_file" 2>/dev/null | sed 's/^commit_style:[[:space:]]*//' | sed 's/^["'\'']//' | sed 's/["'\'']*$//' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]') | ||
| [ -n "$_style_val" ] && _commit_style="$_style_val" |
|
Please address Copilot feedback |
|
@dhruv-15-03 could you follow up soon? Speckit is a moving target. Thx. |
Copilot review feedback on PR github#3413 identified that commit_style parsing didn't strip trailing YAML inline comments (e.g. "commit_style: conventional # team standard"), causing the value to retain a trailing comment fragment and silently skip conventional-mode enforcement. - bash: fix the inline-comment strip regex to use a proper {1,} interval so multiple spaces before '#' are consumed together with the comment, preventing a stray trailing quote character from surviving quote-strip when the value is quoted (e.g. commit_style: "conventional" # x). - powershell: already handled this correctly via \s+#.*$ + Trim(); no behavior change needed there. - tests: add regression coverage for commit_style values with trailing inline comments (bash + pwsh), and a pwsh regression test for the no-changes short-circuit ordering, per additional Copilot suggestion. Assisted-by: GitHub Copilot (model: claude-sonnet-5, autonomous)
|
Posted by GitHub Copilot (model: claude-sonnet-5) on behalf of @dhruv-15-03. Addressed the outstanding Copilot review feedback in c1d245d:
All existing + new tests pass locally (ruff clean, targeted commit_style test classes green). |
Summary
Implements issue #3390: adds a configurable
commit_styleoption (fixed|conventional) to the bundled git extension's auto-commit feature.commit_style: fixed(default) — unchanged, static configured messages.commit_style: conventional— thespeckit.git.commithook now instructs the agent to generate a Conventional Commit message from the diff and pass it explicitly toauto-commit.sh/auto-commit.ps1as a second argument.commit_style: conventionalis set but no generated message is supplied, the scripts fail loudly (stderr message + exit 1) instead of silently committing with the fixed message — while still short-circuiting cleanly when there are no changes to commit.Changes
extensions/git/config-template.yml,extensions/git/git-config.yml: newcommit_styleoption with docs.extensions/git/scripts/bash/auto-commit.sh: optional[generated_message]arg,commit_styleparsing, conventional-mode enforcement (ordered after the "no changes" check).extensions/git/scripts/powershell/auto-commit.ps1: mirrored PowerShell implementation.extensions/git/commands/speckit.git.commit.md: documents the new "Commit Message Styles" section and updated execution/config/graceful-degradation guidance.extensions/git/README.md: documents the new option in the configuration example.tests/extensions/git/test_git_extension.py: newTestAutoCommitBashCommitStyle/TestAutoCommitPowerShellCommitStyleregression tests covering fixed-default, conventional success, conventional missing-message failure, and no-changes short-circuit.Testing
pytest tests/extensions/git/test_git_extension.py -v— all bash/PowerShell tests requiring bash/pwsh skip consistently in this environment (matching existingTestAutoCommitBash/TestAutoCommitPowerShellbehavior via@requires_bash/HAS_PWSH).auto-commit.ps1using Windows PowerShell, since pwsh (PowerShell 7) isn't installed in this environment.pytest tests/(full suite): 3614 passed, 295 skipped, 39 failed — all 39 failures are pre-existing, environment-specific (Windows symlink-permission tests and pwsh-only tests), unrelated to this change.ruff check extensions/git tests/extensions/git: all checks passed.Fixes #3390
This PR was prepared with the assistance of GitHub Copilot (model: claude-sonnet-5, operating autonomously) on behalf of @dhruv-15-03.