зеркало из https://github.com/github/vitess-gh.git
Merge pull request #966 from michael-berlin/golint_precommit_eclipse_fix
Fix golint pre commit hook for non-interactive shell (2nd try).
This commit is contained in:
Коммит
d0de5242c9
|
@ -37,26 +37,34 @@ done
|
|||
|
||||
# git doesn't give us access to user input, so let's steal it.
|
||||
exec < /dev/tty
|
||||
|
||||
echo
|
||||
echo "Lint suggestions were found. They're not enforced, but we're pausing"
|
||||
echo "to let you know before they get clobbered in the scrollback buffer."
|
||||
echo
|
||||
read -r -p 'Press enter to cancel, "s" to step through the warnings or type "ack" to continue: '
|
||||
if [ "$REPLY" = "ack" ]; then
|
||||
exit 0
|
||||
fi
|
||||
if [ "$REPLY" = "s" ]; then
|
||||
first_file="true"
|
||||
if [[ $? -eq 0 ]]; then
|
||||
# interactive shell. Prompt the user.
|
||||
echo
|
||||
echo "Lint suggestions were found. They're not enforced, but we're pausing"
|
||||
echo "to let you know before they get clobbered in the scrollback buffer."
|
||||
echo
|
||||
read -r -p 'Press enter to cancel, "s" to step through the warnings or type "ack" to continue: '
|
||||
if [ "$REPLY" = "ack" ]; then
|
||||
exit 0
|
||||
fi
|
||||
if [ "$REPLY" = "s" ]; then
|
||||
first_file="true"
|
||||
for gofile in "${gofiles_with_warnings[@]}"
|
||||
do
|
||||
echo
|
||||
if [ "$first_file" != "true" ]; then
|
||||
echo "Press enter to show the warnings for the next file."
|
||||
read
|
||||
fi
|
||||
golint $gofile
|
||||
first_file="false"
|
||||
done
|
||||
fi
|
||||
else
|
||||
# non-interactive shell (e.g. called from Eclipse). Just display the errors.
|
||||
for gofile in "${gofiles_with_warnings[@]}"
|
||||
do
|
||||
echo
|
||||
if [ "$first_file" != "true" ]; then
|
||||
echo "Press enter to show the warnings for the next file."
|
||||
read
|
||||
fi
|
||||
golint $gofile
|
||||
first_file="false"
|
||||
done
|
||||
fi
|
||||
exit 1
|
||||
|
|
Загрузка…
Ссылка в новой задаче