У меня есть GIT предварительно нажимной крюк, который вызывает сценарий оболочки под названием pre-push.sh как такмерзавец крючок не работает с входным потоком
#!/bin/bash
#Fail if one script fails and print all info to console
set -ex
#Font variables
underline=`tput smul`
nounderline=`tput rmul`
#Run grunt
grunt;
#Make sure there is only one commit being pushed
printf "\n${underline}Validating Number of Commits${nounderline}\n";
src/scripts/hooks/pre-push/countCommits.sh;
граф совершает как таковой
#!/bin/bash
confirm() {
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
#This script counts the number of commits being pushed and fails if it is greater than 1 commit being pushed
countCommits(){
NUMBER_OF_COMMITS=`git rev-list @{u}.. | wc -l`
if [ "$NUMBER_OF_COMMITS" -gt "1" ]; then
return 1
#exit 1
else
return 0
fi
}
if countCommits; then
printf "\e[0;32mDone, without errors.\e[0m"
else
printf "$NUMBER_OF_COMMITS commits were pushed. We recommend pushing only 1 commit."
if confirm "$NUMBER_OF_COMMITS commits were found. We recommend pushing only 1 commit. Do you wish to continue? [y/N]"; then
:
else
printf "Please squash your commits by running \e[1;34m'git rebase -i'\e[0m\n"
exit 1
fi
fi
при вызове pre -push.sh непосредственно он работает правильно, т.е. ожидает, что пользователь скажет «y» или «n», если у них больше 1 фиксации. Однако, когда я использую его в качестве предварительного нажимной крючка не ждать подсказки пользователю и продолжается вниз по пути не
при вызове pre-push.sh непосредственно
+ src/scripts/hooks/pre-push/countCommits.sh
5 commits were pushed. We recommend pushing only 1 commit. 5 commits were found. We recommend pushing only 1 commit. Do you wish to continue? [y/N] n
Please squash your commits by running 'git rebase -i'
при выполнении GIT толчок
+ src/countCommits.sh
5 commits were pushed. We recommend pushing only 1 commit.Please squash your commits by running 'git rebase -i'
error: failed to push some refs
Как получить git-крючок, чтобы разрешить вход пользователя?
ok есть ли способ использовать этот флаг, чтобы игнорировать эту проверку? в pre -push.sh у меня есть некоторые другие проверки, которые я бы хотел сохранить? – user3626708