Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -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"
16 changes: 13 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -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 "),
],
}

2 changes: 2 additions & 0 deletions deploy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: clevis

services:
api:
build:
Expand Down
Loading