mirror of
https://github.com/AstronautCheetah/frame-tweaks.git
synced 2026-10-17 20:00:18 +02:00
- .cz.toml, dev/check-commit-msg.sh (cz check, or the same pattern without commitizen), in the commit-msg hook and CI; the Release workflow commits as chore(release). - update and get.sh fetch tags with --force; a main checkout that can't fast-forward says how to catch up. - Pins: license_file= URLs at the pinned version; dev/mirror-pins.sh uploads them as <copy>.<project>-<file>; CI requires them.
31 lines
1.4 KiB
Bash
Executable File
31 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Checks that a commit message follows Conventional Commits (.cz.toml; CONTRIBUTING.md, "Commit
|
|
# style"): with commitizen's `cz check` when it's installed, otherwise with the same pattern.
|
|
# Used by the commit-msg hook and CI.
|
|
# dev/check-commit-msg.sh FILE one message
|
|
# dev/check-commit-msg.sh --all [REF] every commit reachable from REF (default HEAD)
|
|
set -euo pipefail
|
|
root=$(git rev-parse --show-toplevel)
|
|
# commitizen's cz_conventional_commits pattern, and the prefixes it lets through unchecked.
|
|
pattern='^(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)(\([^)[:space:]]+\))?!?: [^[:space:]]'
|
|
allowed='^(Merge|Revert|Pull request|fixup!|squash!|amend!)'
|
|
check_file() {
|
|
if command -v cz >/dev/null; then
|
|
(cd "$root" && cz check --commit-msg-file "$1" >/dev/null 2>&1) && return 0
|
|
else
|
|
local subject; subject=$(grep -v '^#' "$1" | sed -n 1p)
|
|
[[ $subject =~ $pattern || $subject =~ $allowed ]] && return 0
|
|
fi
|
|
echo " not a Conventional Commit: $(grep -v '^#' "$1" | sed -n 1p)" >&2
|
|
return 1
|
|
}
|
|
if [ "${1:-}" = --all ]; then
|
|
tmp=$(mktemp); trap 'rm -f "$tmp"' EXIT; bad=0
|
|
for c in $(git rev-list "${2:-HEAD}"); do
|
|
git log -1 --format=%B "$c" > "$tmp"
|
|
check_file "$tmp" || { echo " in commit ${c:0:7}" >&2; bad=1; }
|
|
done
|
|
exit "$bad"
|
|
fi
|
|
check_file "${1:?usage: dev/check-commit-msg.sh FILE | --all [REF]}"
|