mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
apply black to all python scripts
This commit is contained in:
parent
b33e56a05f
commit
21f5d20b9e
@ -11,6 +11,7 @@ RUN apt-get update && env DEBIAN_FRONTEND=noninteractive apt-get install --yes \
|
|||||||
aspell \
|
aspell \
|
||||||
curl \
|
curl \
|
||||||
git \
|
git \
|
||||||
|
file \
|
||||||
libxml2-utils \
|
libxml2-utils \
|
||||||
moreutils \
|
moreutils \
|
||||||
python3-fuzzywuzzy \
|
python3-fuzzywuzzy \
|
||||||
|
@ -4,10 +4,22 @@ set -e
|
|||||||
|
|
||||||
# We check only our code, that's why we skip contrib
|
# We check only our code, that's why we skip contrib
|
||||||
GIT_ROOT=$(git rev-parse --show-cdup)
|
GIT_ROOT=$(git rev-parse --show-cdup)
|
||||||
GIT_ROOT=${GIT_ROOT:-.}
|
GIT_ROOT=${GIT_ROOT:-./}
|
||||||
tmp=$(mktemp)
|
tmp=$(mktemp)
|
||||||
# Find all *.py files in the repo except the contrib directory
|
|
||||||
find_cmd=(find "$GIT_ROOT" -name '*.py' -not -path "$GIT_ROOT/contrib/*")
|
# Find all *.py, *.python files and executable files without extension
|
||||||
|
# that are determined as python scripts by 'file' util
|
||||||
|
# in the repo except the contrib directory.
|
||||||
|
find_cmd=(
|
||||||
|
find "$GIT_ROOT" -type f -not -path "${GIT_ROOT}contrib/*"
|
||||||
|
\(
|
||||||
|
-name '*.py' -or -name "*.python" -or
|
||||||
|
\(
|
||||||
|
-executable -not -name "*.*" -exec sh -c 'file {} | grep -q "Python script"' \;
|
||||||
|
\)
|
||||||
|
\)
|
||||||
|
)
|
||||||
|
|
||||||
if ! "${find_cmd[@]}" -exec black --check --diff {} + 1>"$tmp" 2>&1; then
|
if ! "${find_cmd[@]}" -exec black --check --diff {} + 1>"$tmp" 2>&1; then
|
||||||
# Show the result only if some files need formatting
|
# Show the result only if some files need formatting
|
||||||
cat "$tmp"
|
cat "$tmp"
|
||||||
@ -16,4 +28,5 @@ if ! "${find_cmd[@]}" -exec black --check --diff {} + 1>"$tmp" 2>&1; then
|
|||||||
# Automatically add changed files to stage
|
# Automatically add changed files to stage
|
||||||
"${find_cmd[@]}" -exec git add -u {} + 1>/dev/null 2>&1
|
"${find_cmd[@]}" -exec git add -u {} + 1>/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm "$tmp"
|
rm "$tmp"
|
||||||
|
Loading…
Reference in New Issue
Block a user