Files
podman/hack/commit-subject-check.sh
Kir Kolyshkin bb3f0c9e56 hack: format with shfmt -w
Using shfmt v3.13.1

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-06-09 11:55:16 -07:00

34 lines
759 B
Bash
Executable File

#!/usr/bin/env bash
#
# Check that commit subject lines in a given range are non-empty and no
# longer than $MAX chars. Replaces the former `git-validation -run
# short-subject` check.
#
# Usage: hack/commit-subject-check.sh <git-range>
# e.g. hack/commit-subject-check.sh origin/main..HEAD
set -euo pipefail
MAX=90
if [[ $# -ne 1 ]]; then
echo "Usage: $0 <git-range>" >&2
exit 2
fi
range=$1
rc=0
while IFS=$'\t' read -r sha subject; do
len=${#subject}
if [[ $len -eq 0 ]]; then
echo "$sha: empty commit subject" >&2
rc=1
elif [[ $len -ge $MAX ]]; then
echo "$sha: subject is $len chars (must be < $MAX): $subject" >&2
rc=1
fi
done < <(git log --no-merges --format='%H%x09%s' "$range")
exit $rc