Skip to content

Commit 4832ace

Browse files
committed
build: Add file permissions check to format script
Also do white space checks on more files. Change-Id: Ie6fae6726336bf8ebf3f6aa5c1534d98cd3f9510 Signed-off-by: Greg Tucker <[email protected]>
1 parent fddcb00 commit 4832ace

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

tools/check_format.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fi
2727
if hash indent && indent --version | grep -q GNU; then
2828
echo "Checking C files for coding style..."
2929
for f in `git ls-files '*.c'`; do
30-
[ "$verbose" -gt 0 ] 2> /dev/null && echo "checking $f"
30+
[ "$verbose" -gt 0 ] && echo "checking style on $f"
3131
if ! indent $indent_args -st $f | diff -q $f - >& /dev/null; then
3232
echo " File found with formatting issues: $f"
3333
[ "$verbose" -gt 0 ] 2> /dev/null && indent $indent_args -st $f | diff -u $f -
@@ -41,8 +41,8 @@ fi
4141

4242
if hash grep; then
4343
echo "Checking for dos and whitespace violations..."
44-
for f in `git ls-files '*.c' '*.h' '*.asm' '*.inc' '*.am' '*.txt' '*.md' '*.def' '*.ac' '*.sh' '*.in' 'Makefile*' `; do
45-
[ "$verbose" -gt 0 ] 2> /dev/null && echo "checking $f"
44+
for f in $(git ls-files); do
45+
[ "$verbose" -gt 0 ] && echo "checking whitespace on $f"
4646
if grep -q '[[:space:]]$' $f ; then
4747
echo " File found with trailing whitespace: $f"
4848
rc=1
@@ -54,6 +54,27 @@ if hash grep; then
5454
done
5555
fi
5656

57+
echo "Checking source files for permissions..."
58+
while read -r perm _res0 _res1 f; do
59+
[ -z "$f" ] && continue
60+
[ "$verbose" -gt 0 ] && echo "checking permissions on $f"
61+
if [ "$perm" -ne 100644 ]; then
62+
echo " File found with permissions issue ($perm): $f"
63+
rc=1
64+
fi
65+
done <<< $(git ls-files -s -- ':(exclude)*.sh' ':(exclude)*iindent')
66+
67+
echo "Checking script files for permissions..."
68+
while read -r perm _res0 _res1 f; do
69+
[ -z "$f" ] && continue
70+
[ "$verbose" -gt 0 ] && echo "checking permissions on $f"
71+
if [ "$perm" -ne 100755 ]; then
72+
echo " Script found with permissions issue ($perm): $f"
73+
rc=1
74+
fi
75+
done <<< $(git ls-files -s '*.sh')
76+
77+
5778
echo "Checking for signoff in commit message..."
5879
if ! git log -n 1 --format=%B | grep -q "^Signed-off-by:" ; then
5980
echo " Commit not signed off. Please read src/CONTRIBUTING.md"

0 commit comments

Comments
 (0)