diff --git a/seaweed-block/.github/scripts/post-merge-review-check-test.sh b/seaweed-block/.github/scripts/post-merge-review-check-test.sh index 7cf3d0c8b5..04e52b6287 100644 --- a/seaweed-block/.github/scripts/post-merge-review-check-test.sh +++ b/seaweed-block/.github/scripts/post-merge-review-check-test.sh @@ -107,6 +107,17 @@ for bad in "$empty" "/nonexistent/post-merge-review-allow.txt"; do done rm -f "$empty" +# A list whose last line has no newline keeps that line (here a denial). +unterminated=$(mktemp) +printf '*_test.go\n!core/workspace/*' >"$unterminated" +got=0 +printf 'M\0core/workspace/orch_test.go\0' | bash "$check" "$unterminated" >/dev/null 2>&1 || got=$? +[[ $got == 1 ]] || { echo "FAIL allow list with an unterminated last line: exit $got, want 1"; fail=1; } +got=0 +printf 'M\0cmd/foo/a_test.go\0' | bash "$check" "$unterminated" >/dev/null 2>&1 || got=$? +[[ $got == 0 ]] || { echo "FAIL allow list with an unterminated last line, allowed path: exit $got, want 0"; fail=1; } +rm -f "$unterminated" + # Real Git: names that git quotes in its default output, a rename out of a # denied directory, a retarget onto a base that differs, and test deletes. repo=$(mktemp -d) diff --git a/seaweed-block/.github/scripts/post-merge-review-check.sh b/seaweed-block/.github/scripts/post-merge-review-check.sh index 5875b0b928..918ee3f4bf 100644 --- a/seaweed-block/.github/scripts/post-merge-review-check.sh +++ b/seaweed-block/.github/scripts/post-merge-review-check.sh @@ -16,7 +16,8 @@ if [[ ! -f $allow_file ]]; then fi allow=() deny=() -while IFS= read -r line; do +# A last line without a newline is read too: dropping it could drop a "!". +while IFS= read -r line || [[ -n $line ]]; do line=${line%%#*} line=${line%"${line##*[![:space:]]}"} line=${line#"${line%%[![:space:]]*}"}