From 2bca6c870266dc59f9257c40331d0483a5486a01 Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Mon, 11 Mar 2024 08:55:11 +0100 Subject: [PATCH] Redirect input to terminal only when running through terminal (#8362) Co-authored-by: Timur Karimov --- .husky/pre-push | 7 +++++-- changelog/enhance-pre-push-hook | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelog/enhance-pre-push-hook diff --git a/.husky/pre-push b/.husky/pre-push index 3dc4fa4bcd0..05b3f2a4632 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,8 +1,11 @@ #!/bin/bash . "$(dirname "$0")/_/husky.sh" -# Allows us to read user input below, redirects script's input to the terminal. -exec < /dev/tty +# check if main stream (stdout and stderr) are attached to the terminal +if [ -t 1 ] && [ -t 2 ]; then + # Allows us to read user input below, redirects script's input to the terminal. + exec < /dev/tty +fi PROTECTED_BRANCH=("develop" "trunk") CURRENT_BRANCH=$(git branch --show-current) diff --git a/changelog/enhance-pre-push-hook b/changelog/enhance-pre-push-hook new file mode 100644 index 00000000000..9a3b3e2919c --- /dev/null +++ b/changelog/enhance-pre-push-hook @@ -0,0 +1,4 @@ +Significance: minor +Type: dev + +Ensure pre-push hook understands terminal & non-terminal environments