mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 10:33:59 -05:00
Further improve pre-commit hook
This commit is contained in:
@@ -1,18 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
against='HEAD'
|
||||
|
||||
printf "\033[0;32mRunning tests...\033[0m\n"
|
||||
FORBIDDEN='console.log'
|
||||
FILES_PATTERN='\.(js)(\..+)?$'
|
||||
OUT=0
|
||||
|
||||
printf "\033[0;32mRunning tests...\033[0m\n"
|
||||
|
||||
# Do not commit forbidden elements
|
||||
git diff --cached --name-only | \
|
||||
grep -E $FILES_PATTERN | \
|
||||
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN && printf "Please unstage console.log before commiting\n\033[0;31mAborting commit\033[0m\n" && exit 1
|
||||
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN && printf "Please unstage ${FORBIDDEN} before committing\n\033[0;31mAborting commit\033[0m\n" && exit 1
|
||||
|
||||
make check
|
||||
# Pass lint and mocha tests
|
||||
CHECK_OUTPUT=`make check`
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
printf "%s\n" "${CHECK_OUTPUT}"
|
||||
printf "\033[0;31mAborting commit\033[0m\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Have normalized whitespaces
|
||||
git diff-index --check --cached 'HEAD' --
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
printf "\033[0;31mAborting commit\033[0m\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "\033[0;32mTests pass!\033[0m\n"
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#commentedProperty=This is not expected
|
||||
exampleProperty=value
|
||||
emptyProperty=
|
||||
unusable
|
||||
numericPropertyPositive=42
|
||||
numericPropertyZero=0
|
||||
numericPropertyNegative=-11
|
||||
|
||||
@@ -49,9 +49,6 @@ describe('Properties', () => {
|
||||
it('Ignores commented out properties', () => {
|
||||
should.equal(casesProps("commentedProperty"), undefined);
|
||||
});
|
||||
it('Handles non split properties', () => {
|
||||
should.equal(casesProps("unusable"), undefined)
|
||||
});
|
||||
it('Understands positive integers', () => {
|
||||
should.equal(casesProps("numericPropertyPositive"), 42);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user