From a00531fe8b53afbf8838caefb155eb0a0b0f9758 Mon Sep 17 00:00:00 2001 From: Yaroslav Chvanov Date: Thu, 2 Mar 2023 13:48:03 +0300 Subject: [PATCH] lint: exit early if git ls-files doesn't find anything --- test/python-black-check.sh | 8 +++++++- test/python-ruff-check.sh | 8 +++++++- tools/python-black.sh | 8 +++++++- tools/python-ruff.sh | 8 +++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/test/python-black-check.sh b/test/python-black-check.sh index 93597db8..7a6fd0ab 100755 --- a/test/python-black-check.sh +++ b/test/python-black-check.sh @@ -7,4 +7,10 @@ fi cd "$MESON_SOURCE_ROOT" || exit 101 -black --check $(git ls-files "*.py" "*.py.in") +files=$(git ls-files "*.py" "*.py.in") +if [ -z "$files" ]; then + echo "Git didn't find any files" + exit 77 +fi + +black --check $files diff --git a/test/python-ruff-check.sh b/test/python-ruff-check.sh index f4c7ad16..0d726702 100755 --- a/test/python-ruff-check.sh +++ b/test/python-ruff-check.sh @@ -7,4 +7,10 @@ fi cd "$MESON_SOURCE_ROOT" || exit 101 -ruff check $(git ls-files "*.py" "*.py.in") +files=$(git ls-files "*.py" "*.py.in") +if [ -z "$files" ]; then + echo "Git didn't find any files" + exit 77 +fi + +ruff check $files diff --git a/tools/python-black.sh b/tools/python-black.sh index ada79792..e80a9d95 100755 --- a/tools/python-black.sh +++ b/tools/python-black.sh @@ -7,4 +7,10 @@ fi cd "$MESON_SOURCE_ROOT" || exit 101 -black $(git ls-files "*.py" "*.py.in") +files=$(git ls-files "*.py" "*.py.in") +if [ -z "$files" ]; then + echo "Git didn't find any files" + exit 77 +fi + +black $files diff --git a/tools/python-ruff.sh b/tools/python-ruff.sh index 98de940f..43885b4b 100755 --- a/tools/python-ruff.sh +++ b/tools/python-ruff.sh @@ -7,4 +7,10 @@ fi cd "$MESON_SOURCE_ROOT" || exit 101 -ruff check --fix $(git ls-files "*.py" "*.py.in") +files=$(git ls-files "*.py" "*.py.in") +if [ -z "$files" ]; then + echo "Git didn't find any files" + exit 77 +fi + +ruff check --fix $files