Skip to content

Commit 01a8182

Browse files
committed
Fix non-interactive usage
Because: * Currently, the hook will always prompt for user input if warnings are detected. * This prevents usage in non-interactive contexts such as some Git GUI clients and CI. Notes: * I don't love the test specific `FAKE_TTY` featuring in the hook itself, but I can't think of a way around this right now and I think the non-interactive support is worth it. Credit @ssbarnea with the solution, ref: #18
1 parent e02c04d commit 01a8182

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

hook.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ while true; do
284284

285285
display_warnings
286286

287+
# if non-interactive don't prompt and exit with an error
288+
if [ ! -t 1 ] && [ -z ${FAKE_TTY+x} ]; then
289+
exit 1
290+
fi
291+
287292
# Ask the question (not using "read -p" as it uses stderr not stdout)
288293
echo -en "${BLUE}Proceed with commit? [e/y/n/?] ${NC}"
289294

0 commit comments

Comments
 (0)