From: Daniele Varrazzo Date: Tue, 15 Aug 2023 22:08:48 +0000 (+0100) Subject: feat: add --check mode to sync-to-async script X-Git-Tag: pool-3.2.0~12^2~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba8bab8763c5819b7e0cad1d04917d155ae7b455;p=thirdparty%2Fpsycopg.git feat: add --check mode to sync-to-async script It will be useful to set up a pipeline to check for inconsistencies. --- diff --git a/tools/convert_async_to_sync.sh b/tools/convert_async_to_sync.sh index 4e167a062..76b0e07df 100755 --- a/tools/convert_async_to_sync.sh +++ b/tools/convert_async_to_sync.sh @@ -7,6 +7,16 @@ set -euo pipefail dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "${dir}/.." +check= + +# If --check is used, give an error if files are changed +# (note: it's not a --dry-run) +if [[ ${1:-} == '--check' ]]; then + check=1 +fi + +outputs="" + for async in \ tests/test_client_cursor_async.py \ tests/test_connection_async.py \ @@ -24,4 +34,13 @@ do echo "converting '${async}' -> '${sync}'" >&2 python "${dir}/async_to_sync.py" ${async} > ${sync} black -q ${sync} + outputs="$outputs ${sync}" done + +if [[ $check ]]; then + if ! git diff --exit-code $outputs; then + echo " +ERROR: sync and async files out of sync!" >&2 + exit 1 + fi +fi