File tree 8 files changed +53
-0
lines changed
gix-revision/tests/fixtures
8 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -359,6 +359,14 @@ jobs:
359
359
- name : gix-pack with all features (including wasm)
360
360
run : cd gix-pack && cargo build --all-features --target "$TARGET"
361
361
362
+ check-mode :
363
+ runs-on : ubuntu-latest
364
+
365
+ steps :
366
+ - uses : actions/checkout@v4
367
+ - name : Find scripts with mode/shebang mismatch
368
+ run : etc/check-mode.sh
369
+
362
370
check-packetline :
363
371
strategy :
364
372
fail-fast : false
@@ -441,6 +449,7 @@ jobs:
441
449
- test-32bit-cross
442
450
- lint
443
451
- cargo-deny
452
+ - check-mode
444
453
- check-packetline
445
454
- check-blocking
446
455
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -eu -o pipefail
4
+
5
+ # Go to the worktree's root. (Even if the dir name ends in a newline.)
6
+ root_padded=" $( git rev-parse --show-toplevel && echo -n .) "
7
+ root=" ${root_padded% $' \n .' } "
8
+ cd -- " $root "
9
+
10
+ symbolic_shebang=" $( printf ' #!' | od -An -ta) "
11
+ status=0
12
+
13
+ function check () {
14
+ local mode=" $1 " oid=" $2 " path=" $3 " symbolic_magic
15
+
16
+ # Extract the first two bytes (or less if shorter) and put in symbolic form.
17
+ symbolic_magic=" $( git cat-file blob " $oid " | od -N2 -An -ta) "
18
+
19
+ # Check for inconsistency between the mode and whether `#!` is present.
20
+ if [ " $mode " = 100644 ] && [ " $symbolic_magic " = " $symbolic_shebang " ]; then
21
+ printf ' mode -x but has shebang: %q\n' " $path "
22
+ elif [ " $mode " = 100755 ] && [ " $symbolic_magic " != " $symbolic_shebang " ]; then
23
+ printf ' mode +x but no shebang: %q\n' " $path "
24
+ else
25
+ return 0
26
+ fi
27
+
28
+ status=1
29
+ }
30
+
31
+ # Check regular files named with a `.sh` suffix.
32
+ while read -rd ' ' mode oid _stage_number path; do
33
+ case " $mode " in
34
+ 100644 | 100755)
35
+ check " $mode " " $oid " " $path "
36
+ ;;
37
+ esac
38
+ done < <( git ls-files -sz -- ' *.sh' )
39
+
40
+ exit " $status "
Original file line number Diff line number Diff line change @@ -255,6 +255,10 @@ fmt:
255
255
find-yanked :
256
256
cargo install --debug --locked --no-default-features --features max-pure --path .
257
257
258
+ # Find shell scripts whose +x/-x bits and magic bytes (e.g. `#!`) disagree
259
+ check-mode :
260
+ ./ etc/ check-mode.sh
261
+
258
262
# Delete gix-packetline-blocking/src and regenerate from gix-packetline/src
259
263
copy-packetline :
260
264
./ etc/ copy-packetline.sh
You can’t perform that action at this time.
0 commit comments