Files
podman/hack/commit-subject-check.sh
Kir Kolyshkin f45b4c506a ci: replace git-validation with a small shell script
Since commit def70012b9 git-validation is only used to check if the
commit subject is less than 90 characters.

Drop the vendored git-validation Go tool and the .gitvalidation make
target in favor of hack/commit-subject-check.sh.

This removes a Go build dependency and a vendored tree from
test/tools/ while keeping the same CI and local behavior.

Note the now-removed GIT_CHECK_EXCLUDE was not used by gitvalidation
since commit def70012b9 because it was not checking any specific
files, just the commit subject lengths.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-22 11:43:59 -07:00

34 lines
717 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