diff options
| author | Christopher Warner <cwarner@kernelcode.com> | 2026-10-10 18:42:38 -0400 |
|---|---|---|
| committer | Christopher Warner <cwarner@kernelcode.com> | 2026-10-10 18:42:38 -0400 |
| commit | 78862ba855c6e66cac64a86c25dca6149d8fb2fd (patch) | |
| tree | 8259c5337ba7ef0e08ea25f720770ac79510573c /tests/conventional-commits.test.sh | |
| parent | 50b9b2b4c0db6a5e1d9dd511d062d99ae2e11dd3 (diff) | |
| download | iphone-notes-78862ba855c6e66cac64a86c25dca6149d8fb2fd.tar.gz iphone-notes-78862ba855c6e66cac64a86c25dca6149d8fb2fd.tar.bz2 iphone-notes-78862ba855c6e66cac64a86c25dca6149d8fb2fd.tar.xz iphone-notes-78862ba855c6e66cac64a86c25dca6149d8fb2fd.zip | |
test: cover helpers, dry-run CLI, and conventional commits
Extract pure note helpers for unit tests, add ICLOUD_NOTES_DRY_RUN so create
and status can be exercised without Chromium, and gate git history on
Conventional Commits 1.0.0 subjects.
Co-authored-by: Cursor <cursoragent@cursor.com>
Diffstat (limited to 'tests/conventional-commits.test.sh')
| -rwxr-xr-x | tests/conventional-commits.test.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/conventional-commits.test.sh b/tests/conventional-commits.test.sh new file mode 100755 index 0000000..042b819 --- /dev/null +++ b/tests/conventional-commits.test.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# Enforce Conventional Commits 1.0.0 on every commit subject in this repo. +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +cd "$ROOT" + +fail() { echo "FAIL: $*" >&2; exit 1; } +pass() { echo "ok: $*"; } + +# Same rule as scripts/lib/note-helpers.mjs isConventionalCommitSubject +RE='^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([a-zA-Z0-9._/-]+\))?!?: .+' + +mapfile -t SUBJECTS < <(git log --format=%s) +[[ "${#SUBJECTS[@]}" -gt 0 ]] || fail "no commits" + +bad=0 +for s in "${SUBJECTS[@]}"; do + if [[ ! "$s" =~ $RE ]]; then + echo "non-conventional: $s" >&2 + bad=1 + else + pass "commit: $s" + fi +done +[[ "$bad" -eq 0 ]] || fail "one or more commits are not Conventional Commits" + +# Unit helper agrees with git history +node --input-type=module -e ' +import { isConventionalCommitSubject } from "./scripts/lib/note-helpers.mjs"; +import { execSync } from "node:child_process"; +const subjects = execSync("git log --format=%s", { encoding: "utf8" }) + .trim().split("\n").filter(Boolean); +for (const s of subjects) { + if (!isConventionalCommitSubject(s)) { + console.error("helper rejected:", s); + process.exit(1); + } +} +' + +echo "All conventional-commit checks passed." |
