Add support for multiple git-check-assertions blocks
This commit is contained in:
parent
80ff74cdf9
commit
7e483b8a7f
4 changed files with 31 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue