Merge pull request #3496 from haydenroche5/pre_commit_stash_fix

Modify pre-commit.sh to only stash and stash pop if there are modified files not add to the index
This commit is contained in:
David Garske 2020-11-17 07:54:50 -08:00 committed by GitHub
commit 8fe6186621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,9 +8,15 @@ echo "\n\nSaving current config\n\n"
cp config.status tmp.status
cp wolfssl/options.h tmp.options.h
# stash modified files not part of this commit, don't test them
echo "\n\nStashing any modified files not part of commit\n\n"
git stash -q --keep-index
# stash modified files, if any, that are not part of this commit, don't test
# them
STASHED=0
if ! git diff --quiet
then
STASHED=1
echo "\n\nStashing modified files not part of commit\n\n"
git stash -q --keep-index
fi
# do the commit tests
echo "\n\nRunning commit tests...\n\n"
@ -18,8 +24,11 @@ echo "\n\nRunning commit tests...\n\n"
RESULT=$?
# restore modified files not part of this commit
echo "\n\nPopping any stashed modified files not part of commit\n"
git stash pop -q
if test $STASHED -eq 1
then
echo "\n\nPopping stashed modified files not part of commit\n"
git stash pop -q
fi
# restore current config
echo "\nRestoring current config\n"