|
| 1 | +[pre-commit]: https://pre-commit.com/ |
| 2 | +[commitizen]: https://commitizen-tools.github.io/commitizen/ |
| 3 | +[Conventional Commits]: https://www.conventionalcommits.org |
| 4 | + |
| 5 | + |
| 6 | +# Commit Workflow |
| 7 | + |
| 8 | +## Pre-Commit Hooks |
| 9 | +Pre-commit hooks are scripts that automatically run before a commit is finalized, serving as a quality checkpoint for code changes. `afterpython` uses [pre-commit] to manage these hooks. |
| 10 | + |
| 11 | +After running `ap init`, if you agreed to create a `.pre-commit-config.yaml` file, it will be located in the `afterpython/` folder with some default hooks. Since this configuration file is not at the project root, you need to run `ap pre-commit` (or `ap pc` for short) instead of the `pre-commit` command—it automatically uses the configuration in `afterpython/`. |
| 12 | + |
| 13 | +### Commands |
| 14 | +- `ap pre-commit` (or `ap pc`) — equivalent to `pre-commit --config afterpython/.pre-commit-config.yaml` |
| 15 | + |
| 16 | + |
| 17 | +--- |
| 18 | +## Commitizen |
| 19 | +If you agreed to create a `cz.toml` file during `ap init`, `afterpython` will use [commitizen] to help you write clear, structured commit messages following the [Conventional Commits] specification. |
| 20 | + |
| 21 | +Since the `cz.toml` configuration file is located in `afterpython/` (not the project root), use `ap cz` instead of the standard `cz` command. |
| 22 | + |
| 23 | +### Writing Commit Messages |
| 24 | +**Recommended:** Use `ap commit` to create commits. This command: |
| 25 | +1. Runs pre-commit hooks on changed files to catch issues early |
| 26 | +2. Guides you through an interactive prompt to write a properly formatted commit message |
| 27 | +3. Provides flags to skip checks when needed |
| 28 | + |
| 29 | +**Alternative:** Use `git commit` directly if you're comfortable writing [Conventional Commits] format messages (e.g., `feat: add new feature`, `fix: resolve bug`). Your message must match the format enforced in `cz.toml` and pass pre-commit hook checks. |
| 30 | + |
| 31 | + |
| 32 | +**Bypassing checks:** To commit without running any checks: |
| 33 | +- `git commit --no-verify` — skip pre-commit hooks |
| 34 | +- `git push --no-verify` — skip pre-push hooks |
| 35 | + |
| 36 | +### Commands |
| 37 | +- `ap cz` (or `ap commitizen`) — equivalent to `cz --config afterpython/cz.toml` |
| 38 | +- `ap commit` — wrapper around `cz commit` with additional features: |
| 39 | + - `ap commit --no-cz` — skip commitizen checks in pre-commit hooks |
| 40 | + - `ap commit --no-pc` — skip pre-commit checks before writing the commit message |
| 41 | +- `git commit --no-verify` — skip all pre-commit hooks |
| 42 | +- `git push --no-verify` — skip all pre-push hooks |
| 43 | + |
| 44 | + |
| 45 | +:::{tip} Commitizen Customization |
| 46 | +<!-- :class: dropdown --> |
| 47 | +Customize the commit message format by editing `cz.toml`. |
| 48 | + |
| 49 | +See [Commitizen Customization](https://commitizen-tools.github.io/commitizen/customization/) for details. |
| 50 | +::: |
0 commit comments