Add support for multiple git-check-assertions blocks

This commit is contained in:
Sven van Heugten 2026-03-11 21:54:45 +01:00
parent 80ff74cdf9
commit 7e483b8a7f
No known key found for this signature in database
GPG key ID: D612F88666F4F660
4 changed files with 31 additions and 6 deletions

View file

@ -106,11 +106,11 @@ for commit_hash in "${commits[@]}"; do
echo "Checking out $commit_hash"
git -c advice.detachedHead=false checkout -q "$commit_hash"
commit_msg="$(git log -1 --format=%B "$commit_hash")"
# shellcheck disable=SC2016
block="$(printf '%s\n' "$commit_msg" |
sed -n '/^```git-check-assertions[[:space:]]*$/,/^```[[:space:]]*$/p' |
sed '1d;$d')"
if [ -n "$block" ]; then
mapfile -d '' -t blocks < <(
printf '%s\n' "$commit_msg" |
perl -0777 -ne 'while (/^```git-check-assertions\s*\n(.*?)^```\s*$/msg){ print $1, "\0" }'
)
for block in "${blocks[@]}"; do
echo "git-check-assertions block in $commit_hash:"
printf '%s\n' "$block" | sed 's/^/> /'
if ! bash -euo pipefail -c "$block"; then
@ -121,7 +121,7 @@ for commit_hash in "${commits[@]}"; do
exit 1
fi
restore
fi
done
printf '%s\n' "$commit_hash" >>.git-check-assertions-cache
echo
done