Fix trailing whitespace check in Windows and Linux

Previous check in check.bat considered only uncommitted changes.
This commit is contained in:
azeemshatp
2020-08-18 12:14:01 +02:00
committed by Martin Jäger
parent d2e833716a
commit 3aada5dbcc
2 changed files with 18 additions and 6 deletions
+11 -5
View File
@@ -1,10 +1,16 @@
@ECHO OFF
:: This batch file performs the same checks as TravisCI and should be run after each commit and before
:: pushing the commits
:: This batch file performs the same checks as TravisCI and should be run after each commit and
:: before pushing the commits
echo "---------- Trailing whitespace check -------------"
REM git diff --check 'git rev-list --max-count=1 --reverse HEAD' ..$TRAVIS_BRANCH
git diff --check master
:: check uncommitted changes
git diff --check HEAD
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
)
:: check all commits starting from initial commit
for /F %i in ('"git rev-list --max-parents=0 HEAD"') do git diff --check %i..HEAD
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
@@ -31,4 +37,4 @@ if errorlevel 1 (
exit /b %errorlevel%
)
echo "---------- All tests passed -------------"
echo "---------- All tests passed -------------"
+7 -1
View File
@@ -5,7 +5,13 @@
#
echo "---------- Trailing whitespace check -------------"
git diff --check `git rev-list HEAD | tail -n 1`..$TRAVIS_BRANCH
# check uncommitted changes
git diff --check HEAD
if [ $? != 0 ]; then
exit 1;
fi
# check all commits starting from initial commit
git diff --check `git rev-list --max-parents=0 HEAD`..HEAD
if [ $? != 0 ]; then
exit 1;
fi