Skip to content

Commit b9166b7

Browse files
Merge branch 'pytorch:main' into num_input_validation
2 parents 8d95704 + 5e5cea8 commit b9166b7

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

backends/arm/scripts/pre-push

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7+
# Calling this script with any argument is equal to launching it in
8+
# non-interactive mode. "$#" gives the number of positional arguments.
9+
[ "$#" -eq 0 ] && is_script_interactive=1 || is_script_interactive=0
10+
711
RESET='\e[0m'
812
RED='\e[31m'
913
GREEN='\e[32m'
@@ -31,8 +35,10 @@ VERBS="Add|Fix|Update|Refactor|Improve|Remove|Change|Implement|Create|Modify|"\
3135

3236
# Remote branch
3337
REMOTE=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null)
34-
35-
if [ -z "$REMOTE" ]; then
38+
if [ $is_script_interactive -eq 0 ]; then
39+
# Just use the one commit
40+
COMMITS=$(git rev-list HEAD -n 1)
41+
elif [ -z "$REMOTE" ]; then
3642
echo -e "${WARNING} Could not find upstream branch to compare to."
3743
echo "Please specify the number of commits you are pushing."
3844
echo -n "Enter number of commits to check (default 1): " > /dev/tty
@@ -155,14 +161,17 @@ for COMMIT in ${COMMITS}; do
155161
if [[ ! "$SUBJECT" =~ ^"Arm backend":\ (${VERBS}) ]]; then
156162
echo -e "${WARNING} Subject should start with 'Arm backend: '"\
157163
"followed by an imperative verb." >&2
158-
echo -n "There are warnings in your commit message. Do you want to"\
159-
"ignore the warning (y/N): " > /dev/tty
160164

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

163-
# Check user input for warnings
164-
if [[ ! "$USER_INPUT" =~ ^[Yy]$ ]]; then
165-
FAILED=1
169+
read USER_INPUT < /dev/tty
170+
171+
# Check user input for warnings
172+
if [[ ! "$USER_INPUT" =~ ^[Yy]$ ]]; then
173+
FAILED=1
174+
fi
166175
fi
167176
fi
168177

0 commit comments

Comments
 (0)