From b30d1f6801696e8e80d4a8237f118e2c5ef1e9c6 Mon Sep 17 00:00:00 2001 From: Alitzel Macias Date: Wed, 8 Jul 2026 14:02:05 +0200 Subject: [PATCH 1/2] Fix pre-commit script not preventing commit --- advanced/Exercise_7_git-hooks.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/advanced/Exercise_7_git-hooks.md b/advanced/Exercise_7_git-hooks.md index 04f9bbd..9d3879b 100644 --- a/advanced/Exercise_7_git-hooks.md +++ b/advanced/Exercise_7_git-hooks.md @@ -76,11 +76,15 @@ Integrate another *pre-commit* hook from the above repository into your workflow # This is the main pre-commit hook script. +status=0 + # Run the whitespace check script. -.git/hooks/pre-commit-whitespace +.git/hooks/pre-commit-whitespace || status=1 # Run the name and email verification script. -.git/hooks/pre-commit-verify-name-and-email +.git/hooks/pre-commit-verify-name-and-email || status=1 + +exit $status ``` > **Hint:** Don't forget that all scripts need to be executable! From 31e270b4511c924f857beef1da12a30c5669eee9 Mon Sep 17 00:00:00 2001 From: Alitzel Macias Date: Thu, 9 Jul 2026 11:44:53 +0200 Subject: [PATCH 2/2] Add comment to explain use of status --- advanced/Exercise_7_git-hooks.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/advanced/Exercise_7_git-hooks.md b/advanced/Exercise_7_git-hooks.md index 9d3879b..e17815b 100644 --- a/advanced/Exercise_7_git-hooks.md +++ b/advanced/Exercise_7_git-hooks.md @@ -76,6 +76,9 @@ Integrate another *pre-commit* hook from the above repository into your workflow # This is the main pre-commit hook script. +# Track whether any hook fails. +# 0: all checks have passed so far; +# 1: at least one check failed. status=0 # Run the whitespace check script.