ci: handle CRLF in git commit messages when detecting binary files

pull/14008/head
Mark Rushakoff 2019-05-28 16:15:19 -07:00 committed by Mark Rushakoff
parent ebdbc394fc
commit 4866ef918b
1 changed files with 2 additions and 1 deletions

View File

@ -26,7 +26,8 @@ for rev in $(git rev-list "$1"); do
for binFile in $(git log -1 --format='' --stat=255 "$rev" | grep ' Bin 0 ->' | cut -d '|' -f 1 | awk '{$1=$1;print}'); do
# We have found a new binary file in $rev.
# Was it in the commit's whitelist?
if git log -1 --format=%b "$rev" | grep -q -F -x "Adds-Binary: $binFile"; then
# (GitHub seems to use \r\n on Squash&Merge commit messages, which doesn't play well with grep -x; hence the awk line.)
if git log -1 --format=%b "$rev" | awk '{ sub("\r$", ""); print }' | grep -q -F -x "Adds-Binary: $binFile"; then
# Yes it was. Skip this file.
echo "Revision $rev $(git log -1 --format='[%s]' "$rev") added whitelisted binary file: $binFile"
continue