Git Commit with Quality Gates
Enforce code quality before every commit.
Workflow (MANDATORY ORDER)
- Quality Gates (BLOCKING - must pass)
```bash
./scripts/quality-gates.sh
```
- Validates >90% test coverage
- Runs all tests with strict warnings
- Checks security vulnerabilities
- Verifies code quality standards
- Checks for
.pyor.shfiles in repository root (forbidden)
If quality gates FAIL: STOP. Fix issues before proceeding.
- Check Status
```bash
git status
git diff --stat
```
- Stage Changes
```bash
git add -p # Interactive staging for atomic commits
# OR
git add <specific-files>
```
- Create Commit (use message format below)
```bash
git commit
```
- Sync with Remote
```bash
git pull --rebase
```
- Handle Conflicts (if any)
- STOP - DO NOT AUTO-FIX
- Notify user for manual resolution
- Only proceed after user confirms resolution
- Push
```bash
git push
```
Commit Message Format
type(scope): Brief description (50 chars max)
- Why this change was necessary from user perspective
- What problem it solves or capability it enables
- Reference issue/ticket numbers if applicable
Commit Types
| Type | Purpose |
|------|---------|
| feat | New user-facing feature |
| fix | Bug fix resolving user issue |
| docs | Documentation changes |
| refactor | Code restructure (no user-facing changes) |
| perf | Performance improvement |
| test | Test additions/changes |
| chore | Build/dependency updates |
Message Rules
- Subject: 50 chars max, capitalized, no period
- Body: Wrap at 72 chars
- Use imperative mood: "Add feature" not "Added feature"
- Explain WHY from user perspective, not WHAT code changed
Examples
Good:
feat(search): Add filters to help users find documents faster
Users were spending too much time scrolling through results.
New filters reduce search time by 60% in user testing.
Fixes #123
Bad:
improved stuff
Atomic Commit Principle
- Each commit = ONE logical change
- Commit must compile and pass tests
- Use
git add -pfor partial staging
Repairing Existing Commits on a PR Branch
CI enforces commitlint (commitlint.config.cjs): header ≤ 100 chars AND every
body/footer line ≤ 100 chars. When a PR branch already fails Commit Message
Lint (LESSON-023/024):
# 1. Enumerate failures locally against the PR base
npx commitlint --from <base-sha> --to HEAD --verbose
# 2. Drop no-op noise commits non-interactively (e.g. re-trigger commits)
GIT_SEQUENCE_EDITOR='sed -i "/re-trigger workflow runs/d"' git rebase -i <base-sha>
# 3. Rewrap every long line mechanically, without changing content
# (fold -s keeps word boundaries; verify the content diff is empty)
git filter-branch -f --msg-filter 'fold -s -w 100' -- <base-sha>..HEAD
git diff <old-head-sha> HEAD --stat # must be empty
npx commitlint --from <base-sha> --to HEAD --verbose # 0 problems
# 4. Push the rewritten history
# --force-with-lease only; never --force when others may have pulled
git push --force-with-lease origin <branch>
Also:
- Run
cargo fmt --allbefore pushing — CI Quick Check fails on fmt drift. - Never add an empty commit to make a real failure go away; fix the
underlying cause. An empty commit is the sanctioned re-trigger when
statusCheckRollup is holding stale FAILURE rows for a name that already
reports SUCCESS, because those rows only clear on a fresh SHA (LESSON-052).
Say which in the message: chore: re-trigger CI after <reason>.
- Never put a GitHub CI skip-control token in a commit message or PR body — not
even quoted in prose describing it, since the matcher scans the whole head
message and the branch then has zero runs (sensor commit-ci-tokens,
commit-msg hook, LESSON-065).
References
Optional Pre-Push Checks
For larger changes:
./scripts/check-doctests.sh
./scripts/check_performance_regression.sh