Block files without trailing newlines
Add a pre-submit check to ensure that files have a newline character at the end. Please see https://android.googlesource.com/platform/tools/repohooks/ for documentation on how PREUPLOAD hooks work. Test: created a change and watched the presubmit check reject it. Change-Id: Id0528cb1bd6fa9c4483ba43720839832f4fec34d
This commit is contained in:
parent
cb4f5b3c5d
commit
16b7f0a14c
2 changed files with 15 additions and 0 deletions
2
PREUPLOAD.cfg
Normal file
2
PREUPLOAD.cfg
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[Hook Scripts]
|
||||||
|
whitespace = tools/whitespace.sh ${PREUPLOAD_FILES}
|
13
tools/whitespace.sh
Executable file
13
tools/whitespace.sh
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
RESULT=0
|
||||||
|
|
||||||
|
for i in "$@"; do
|
||||||
|
a="`tail -c 1 "$i"`"
|
||||||
|
if [ "$a" != "" ]; then
|
||||||
|
echo "$i does not have a trailing newline" 1>&2
|
||||||
|
RESULT=-1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit $RESULT
|
Loading…
Reference in a new issue