diff --git a/.husky/commit-msg b/.husky/commit-msg index a110112..e5c38d2 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,2 +1,5 @@ #!/usr/bin/env sh -npx --no -- commitlint --edit "$1" +# Same Conventional Commit rules as CI (.github/workflows/ci.yml). On failure Git +# aborts this commit; fix the message and run git commit again. +printf '%s\n' "Commit message: checking (commitlint, verbose)…" +commitlint --verbose --edit "$1" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4d14eb7..3ee5077 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,13 +41,23 @@ The repo uses `.gitattributes` so text files are stored with **LF**. On Windows, ## Git hooks (Husky) -After `npm ci` at the repo root: +After `npm ci` at the **repository root**, Git uses Husky (`core.hooksPath` → `.husky/_`). Then: -- **`pre-commit`** runs `npm --prefix apps/ui run typecheck`. Ensure `apps/ui` dependencies are installed so this succeeds. -- **`commit-msg`** runs [Commitlint](https://commitlint.js.org/) with the [Conventional Commits](https://www.conventionalcommits.org/) preset (`@commitlint/config-conventional`). +- **`pre-commit`** runs before the commit is recorded. It runs `npm --prefix apps/ui run typecheck`. Install UI deps (`apps/ui/npm ci`) so this can succeed. +- **`commit-msg`** runs **immediately after** you supply a message—whether from `git commit -m "your subject"` or from the editor. It runs the same [Commitlint](https://commitlint.js.org/) rules as CI ([Conventional Commits](https://www.conventionalcommits.org/) via `@commitlint/config-conventional`), with **`--verbose`** output like the workflow. + +If Commitlint fails, **Git does not create the commit**. You will see the errors in your terminal; fix the message and run `git commit` again (no need to wait for CI to discover the problem). + +**Hooks not running?** Run `npm ci` (or `npm install`) once at the repo root. If you only install dependencies under `apps/ui`, root Husky never runs and commits will not be checked locally. To bypass hooks in exceptional cases (not recommended for routine work): `git commit --no-verify`. +**Dry-run a message without committing** (from repo root, after `npm ci`): + +```bash +printf '%s\n' 'feat(ui): example valid message' | npx --no -- commitlint --verbose +``` + ## Commit messages Use **Conventional Commits**, for example: diff --git a/commitlint.config.cjs b/commitlint.config.cjs index 0952922..f5c5796 100644 --- a/commitlint.config.cjs +++ b/commitlint.config.cjs @@ -1,4 +1,9 @@ module.exports = { extends: ["@commitlint/config-conventional"], + ignores: [ + (message) => message.startsWith("Merge pull request "), + (message) => message.startsWith("Merge branch "), + (message) => message.startsWith("Merge remote-tracking branch "), + ], } diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 8515cbf..47db799 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -1,3 +1,5 @@ +name: clevis + services: api: build: