Pull request 2302: upd-all
Squashed commit of the following: commit f920006277f39b74c803139af2a9039aa45effae Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Fri Nov 8 16:14:41 2024 +0300 all: fix pre-commit; upd dnsproxy commit 391f79b244348c6075f5ba0fccfb8882791bf3f1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Nov 7 18:53:28 2024 +0300 scripts: imp install commit 35324db80b591831c32b7ea45930eefee82a6320 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Nov 7 18:20:23 2024 +0300 all: imp docs, scripts commit d2724cfaefdb8659efbdb5bf181a28721a909f07 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Nov 7 17:26:23 2024 +0300 all: upd go, deps, tools, scripts
This commit is contained in:
@@ -2,81 +2,78 @@
|
||||
|
||||
set -e -f -u
|
||||
|
||||
# This comment is used to simplify checking local copies of the script.
|
||||
# Bump this number every time a significant change is made to this
|
||||
# script.
|
||||
# This comment is used to simplify checking local copies of the script. Bump
|
||||
# this number every time a significant change is made to this script.
|
||||
#
|
||||
# AdGuard-Project-Version: 3
|
||||
# AdGuard-Project-Version: 5
|
||||
|
||||
# TODO(a.garipov): Add pre-merge-commit.
|
||||
|
||||
# Only show interactive prompts if there a terminal is attached to
|
||||
# stdout. While this technically doesn't guarantee that reading from
|
||||
# /dev/tty works, this should work reasonably well on all of our
|
||||
# supported development systems and in most terminal emulators.
|
||||
# Only show interactive prompts if there a terminal is attached to stdout.
|
||||
# While this technically doesn't guarantee that reading from /dev/tty works,
|
||||
# this should work reasonably well on all of our supported development systems
|
||||
# and in most terminal emulators.
|
||||
is_tty='0'
|
||||
if [ -t '1' ]
|
||||
then
|
||||
if [ -t '1' ]; then
|
||||
is_tty='1'
|
||||
fi
|
||||
readonly is_tty
|
||||
|
||||
# prompt is a helper that prompts the user for interactive input if that
|
||||
# can be done. If there is no terminal attached, it sleeps for two
|
||||
# seconds, giving the programmer some time to react, and returns with
|
||||
# a zero exit code.
|
||||
# prompt is a helper that prompts the user for interactive input if that can be
|
||||
# done. If there is no terminal attached, it sleeps for two seconds, giving the
|
||||
# programmer some time to react, and returns with a zero exit code.
|
||||
prompt() {
|
||||
if [ "$is_tty" -eq '0' ]
|
||||
then
|
||||
if [ "$is_tty" -eq '0' ]; then
|
||||
sleep 2
|
||||
|
||||
return 0
|
||||
fi
|
||||
|
||||
while true
|
||||
do
|
||||
while true; do
|
||||
printf 'commit anyway? y/[n]: '
|
||||
read -r ans < /dev/tty
|
||||
read -r ans </dev/tty
|
||||
|
||||
case "$ans"
|
||||
in
|
||||
('y'|'Y')
|
||||
case "$ans" in
|
||||
'y' | 'Y')
|
||||
break
|
||||
;;
|
||||
(''|'n'|'N')
|
||||
'' | 'n' | 'N')
|
||||
exit 1
|
||||
;;
|
||||
(*)
|
||||
*)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Warn the programmer about unstaged changes and untracked files, but do
|
||||
# not fail the commit, because those changes might be temporary or for
|
||||
# a different branch.
|
||||
# Warn the programmer about unstaged changes and untracked files, but do not
|
||||
# fail the commit, because those changes might be temporary or for a different
|
||||
# branch.
|
||||
#
|
||||
# shellcheck disable=SC2016
|
||||
awk_prog='substr($2, 2, 1) != "." { print $9; } $1 == "?" { print $2; }'
|
||||
readonly awk_prog
|
||||
|
||||
unstaged="$( git status --porcelain=2 | awk "$awk_prog" )"
|
||||
unstaged="$(git status --porcelain=2 | awk "$awk_prog")"
|
||||
readonly unstaged
|
||||
|
||||
if [ "$unstaged" != '' ]
|
||||
then
|
||||
if [ "$unstaged" != '' ]; then
|
||||
printf 'WARNING: you have unstaged changes:\n\n%s\n\n' "$unstaged"
|
||||
prompt
|
||||
fi
|
||||
|
||||
# Warn the programmer about temporary todos, but do not fail the commit,
|
||||
# because the commit could be in a temporary branch.
|
||||
temp_todos="$( git grep -e 'TODO.*!!' -- ':!scripts/hooks/pre-commit' || : )"
|
||||
# Warn the programmer about temporary todos and skel FIXMEs, but do not fail the
|
||||
# commit, because the commit could be in a temporary branch.
|
||||
temp_todos="$(
|
||||
git grep -e 'FIXME' -e 'TODO.*!!' -- \
|
||||
':!./scripts/hooks/pre-commit' \
|
||||
':!./client' \
|
||||
|| :
|
||||
)"
|
||||
readonly temp_todos
|
||||
|
||||
if [ "$temp_todos" != '' ]
|
||||
then
|
||||
if [ "$temp_todos" != '' ]; then
|
||||
printf 'WARNING: you have temporary todos:\n\n%s\n\n' "$temp_todos"
|
||||
prompt
|
||||
fi
|
||||
@@ -84,32 +81,22 @@ fi
|
||||
verbose="${VERBOSE:-0}"
|
||||
readonly verbose
|
||||
|
||||
if [ "$( git diff --cached --name-only -- 'client/*.js' || true )" != '' ]
|
||||
then
|
||||
make VERBOSE="$verbose" js-lint js-test
|
||||
fi
|
||||
|
||||
if [ "$( git diff --cached --name-only -- '*.go' '*.mod' 'Makefile' || true )" != '' ]
|
||||
then
|
||||
make VERBOSE="$verbose" go-os-check go-lint go-test
|
||||
fi
|
||||
|
||||
if [ "$( git diff --cached --name-only -- '*.md' || true )" != '' ]
|
||||
then
|
||||
if [ "$(git diff --cached --name-only -- '*.md' || :)" != '' ]; then
|
||||
make VERBOSE="$verbose" md-lint
|
||||
fi
|
||||
|
||||
if [ "$( git diff --cached --name-only -- '*.sh' || true )" != '' ]
|
||||
then
|
||||
if [ "$(git diff --cached --name-only -- '*.sh' || :)" != '' ]; then
|
||||
make VERBOSE="$verbose" sh-lint
|
||||
fi
|
||||
|
||||
if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' || true )" != '' ]
|
||||
then
|
||||
if [ "$(git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' || :)" != '' ]; then
|
||||
make VERBOSE="$verbose" txt-lint
|
||||
fi
|
||||
|
||||
if [ "$( git diff --cached --name-only -- './openapi/openapi.yaml' || true )" != '' ]
|
||||
then
|
||||
if [ "$(git diff --cached --name-only -- '*.go' '*.mod' 'Makefile' || :)" != '' ]; then
|
||||
make VERBOSE="$verbose" go-os-check go-lint go-test
|
||||
fi
|
||||
|
||||
if [ "$(git diff --cached --name-only -- './openapi/openapi.yaml' || :)" != '' ]; then
|
||||
make VERBOSE="$verbose" openapi-lint
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user