spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

feat(extensions): port git extension scripts to Python

Open marcelsafin opened this issue 4 months ago • 1 comments

Summary

Fixes #3282 — part of #3277. Last script port in the porting phase: extensions/git/scripts/{bash,powershell}/ now has Python twins in extensions/git/scripts/python/.

Changes

  • git_common.py — has_git, effective_branch_name, check_feature_branch (port of git-common.sh)
  • initialize_repo.py — repo init with configurable initial commit message
  • auto_commit.py — per-event auto-commit, mirroring the line-based git-config.yml parser including the default/explicit-false precedence rules
  • create_new_feature_branch.py — full port: slug generation with stop-word filtering and acronym handling, sequential numbering across specs/local branches/remote refs, branch_template/branch_prefix with scoped numbering, GIT_BRANCH_NAME override, 244-byte truncation, SPECIFY_INIT_DIR via the core common.py resolver (same refusal as bash when core scripts are missing)

Same conventions as the merged check-prerequisites PoC and the #3280/#3281 ports: stdlib only, standalone scripts, no runtime wiring changes.

Testing

43 new tests in tests/extensions/git/test_git_extension_python_parity.py. The parity tests run each bash script and its Python twin in identical twin projects and assert matching stdout, exit codes, stderr, and resulting git state (branches created, commit messages). Covers branch creation and commit behavior per the issue's acceptance criteria, plus template validation errors, existing-branch handling, and no-git degradation.

  • uv run pytest tests/extensions/git/ — 97 passed
  • Full suite: 3847 passed, 105 skipped
  • uvx ruff check — clean

Checklist

  • [x] Tests pass locally
  • [x] Lint passes
  • [x] I did use AI assistance for this contribution

marcelsafin avatar Jul 07 '26 20:07 marcelsafin

@copilot review

marcelsafin avatar Jul 13 '26 22:07 marcelsafin

Please address Copilot feedback

mnriem avatar Jul 14 '26 12:07 mnriem

@copilot review

marcelsafin avatar Jul 14 '26 13:07 marcelsafin

@copilot review

marcelsafin avatar Jul 14 '26 13:07 marcelsafin

@copilot review

marcelsafin avatar Jul 14 '26 13:07 marcelsafin

@copilot review

marcelsafin avatar Jul 14 '26 13:07 marcelsafin

@copilot review

marcelsafin avatar Jul 14 '26 14:07 marcelsafin

Thank you!

mnriem avatar Jul 14 '26 14:07 mnriem