Skip to content

Arm backend: Add non-interactive in git hook #10712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions backends/arm/scripts/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Calling this script with any argument is equal to launching it in
# non-interactive mode. "$#" gives the number of positional arguments.
[ "$#" -eq 0 ] && is_script_interactive=1 || is_script_interactive=0

RESET='\e[0m'
RED='\e[31m'
GREEN='\e[32m'
Expand Down Expand Up @@ -31,8 +35,10 @@ VERBS="Add|Fix|Update|Refactor|Improve|Remove|Change|Implement|Create|Modify|"\

# Remote branch
REMOTE=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null)

if [ -z "$REMOTE" ]; then
if [ $is_script_interactive -eq 0 ]; then
# Just use the one commit
COMMITS=$(git rev-list HEAD -n 1)
elif [ -z "$REMOTE" ]; then
echo -e "${WARNING} Could not find upstream branch to compare to."
echo "Please specify the number of commits you are pushing."
echo -n "Enter number of commits to check (default 1): " > /dev/tty
Expand Down Expand Up @@ -155,14 +161,17 @@ for COMMIT in ${COMMITS}; do
if [[ ! "$SUBJECT" =~ ^"Arm backend":\ (${VERBS}) ]]; then
echo -e "${WARNING} Subject should start with 'Arm backend: '"\
"followed by an imperative verb." >&2
echo -n "There are warnings in your commit message. Do you want to"\
"ignore the warning (y/N): " > /dev/tty

read USER_INPUT < /dev/tty
if [ $is_script_interactive -eq 1 ]; then
echo -n "There are warnings in your commit message. Do you want to"\
"ignore the warning (y/N): " > /dev/tty

# Check user input for warnings
if [[ ! "$USER_INPUT" =~ ^[Yy]$ ]]; then
FAILED=1
read USER_INPUT < /dev/tty

# Check user input for warnings
if [[ ! "$USER_INPUT" =~ ^[Yy]$ ]]; then
FAILED=1
fi
fi
fi

Expand Down
Loading