From 8ff790343d702be4c9fe55e3519d89a8501d4bf9 Mon Sep 17 00:00:00 2001 From: Emma Vukelj Date: Fri, 19 Jul 2019 14:46:13 -0700 Subject: Toolchain-Utils: Fix bug when no files to lint/check This CL fixes a bug in the previous one editing pre-submit which caused presubmit to fail when no new files have been added. BUG=None TEST=created new branches, confirmed presubmit is run correctly Change-Id: I1a1b968220e60db12d05bbdab25646bfe2eb42e0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1710022 Reviewed-by: George Burgess Reviewed-by: Caroline Tice Tested-by: Emma Vukelj --- toolchain_utils_githooks/check-presubmit | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'toolchain_utils_githooks') diff --git a/toolchain_utils_githooks/check-presubmit b/toolchain_utils_githooks/check-presubmit index 713e3add..0f770234 100755 --- a/toolchain_utils_githooks/check-presubmit +++ b/toolchain_utils_githooks/check-presubmit @@ -38,18 +38,22 @@ spawn_child() { # only lint existing files +files_exist=false declare -a to_lint for file; do if [[ -f "${file}" ]]; then + files_exist=true to_lint+=("${file}") fi done # We have a few things to do in parallel here. To avoid interleaving their # output, we pipe them all to tempfiles, then cat those tempfiles. -spawn_child "${mydir}/check-lint" "${to_lint[@]}" -spawn_child "${mydir}/check-format" "${to_lint[@]}" -spawn_child "${mydir}/../run_tests_for.py" "${to_lint[@]}" +if "${files_exist}"; then + spawn_child "${mydir}/check-lint" "${to_lint[@]}" + spawn_child "${mydir}/check-format" "${to_lint[@]}" + spawn_child "${mydir}/../run_tests_for.py" "${to_lint[@]}" +fi success=true for i in "${!child_pids[@]}"; do -- cgit v1.2.3