Skip to content

Commit bdcf3f5

Browse files
committed
Stash uncommitted changes to prevent false positive test and lint results
1 parent 891358d commit bdcf3f5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tools/git/hooks/pre-commit

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,19 @@ on_error() {
6868

6969
# Runs clean-up tasks.
7070
cleanup() {
71+
# Restore stashed changes to the working tree:
72+
git stash pop -q
73+
7174
echo '' >&2
7275
}
7376

77+
# Runs initialization tasks.
78+
init() {
79+
# Stash any changes to the working tree that are not going to be committed:
80+
git stash -q --keep-index
81+
return 0
82+
}
83+
7484
# Checks for non-ASCII filenames (to ensure cross platform portability).
7585
check_filenames() {
7686
local num_files
@@ -340,6 +350,10 @@ run_lint() {
340350

341351
# Main execution sequence.
342352
main() {
353+
init
354+
if [[ "$?" -ne 0 ]]; then
355+
on_error 1
356+
fi
343357
check_filenames
344358
if [[ "$?" -ne 0 ]]; then
345359
on_error 1

0 commit comments

Comments
 (0)