Я просто пытаюсь убить-сервер adb, он работает для меня:
PS C:\Users\languoguang> adb devices
List of devices attached
MKJ0117A19000186 unauthorized
PS C:\Users\languoguang> adb shell
error: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
убить и запустить adb-сервер:
PS C:\Users\languoguang> adb kill-server
PS C:\Users\languoguang> adb start-server
* daemon not running; starting now at tcp:12345
* daemon started successfully
PS C:\Users\languoguang> adb devices
List of devices attached
MKJ0117A19000186 device
В итоге я получил работающий хук pre-push
(установлен в .git/hooks/pre-push
и запустил chmod +x
на нем):
(Пожалуйста, рассмотрите это Public Domain, через посвящение CC0 .)
echo "Running pre-push hook..."
# Grep below should match the following cases from git diff:
# +++ testserver.js
# +console.log(djsdlkjd)
# + ... console.log(djsdlkjd)
# For an explanation of the regex, see
# https://regex101.com/r/92ysUf/1
searchOutput=$(git --no-pager diff -G"console.log" master...HEAD | perl -ne'print if m{^(\+{1}|\+{3})(?!\+)( |.*?\bconsole.log)}')
# If $searchOutput is blank, wc -l will show it as having 1 line.
# Thus, we will check below whether it has >1 line, and, if so,
# print it and a warning.
if [ $(echo "$searchOutput" | wc -l) -gt 1 ]
then
echo "\n----------------\n"
echo "WARNING: The branch you are pushing contains at least one added console.log(). Here is the abbreviated git diff output:\n"
echo "$searchOutput"
echo "\nContinuing with the push; you may want to remove the lines above in a future commit, though."
echo "\n----------------\n"
fi
exit
Теперь это будет напоминать мне каждый раз, когда я нажимаю, если (и где) в моей текущей ветке остаются console.log
вызовы.
Я публикую этот ответ, потому что он может помочь будущим читателям не только понять, как это сделать, но и как искать исходный код текущей ветки git
.