Skip to content

Commit

Permalink
Merge pull request #1709 from EliahKagan/run-ci/mode-next
Browse files Browse the repository at this point in the history
Fix `check-mode.sh` display of leading-whitespace paths
  • Loading branch information
Byron authored Nov 28, 2024
2 parents 34efe03 + 530948d commit ee33221
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions etc/check-mode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cd -- "$root"
symbolic_shebang="$(printf '#!' | od -An -ta)"
status=0

function check () {
function check_item () {
local mode="$1" oid="$2" path="$3" symbolic_magic

# Extract the first two bytes (or less if shorter) and put in symbolic form.
Expand All @@ -28,11 +28,18 @@ function check () {
status=1
}

readonly record_pattern='^([0-7]+) ([[:xdigit:]]+) [[:digit:]]+'$'\t''(.+)$'

# Check regular files named with a `.sh` suffix.
while read -rd '' mode oid _stage_number path; do
while IFS= read -rd '' record; do
[[ $record =~ $record_pattern ]] || exit 2 # bash 3.2 `set -e` doesn't cover this.
mode="${BASH_REMATCH[1]}"
oid="${BASH_REMATCH[2]}"
path="${BASH_REMATCH[3]}"

case "$mode" in
100644 | 100755)
check "$mode" "$oid" "$path"
check_item "$mode" "$oid" "$path"
;;
esac
done < <(git ls-files -sz -- '*.sh')
Expand Down

0 comments on commit ee33221

Please sign in to comment.