From 6ec8bcd32c31ba30dbf73f5ae055da293992fe0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Thu, 2 Jan 2025 09:38:34 +0100 Subject: [PATCH] chore: optimise for loop --- .github/scripts/changed-modules.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/scripts/changed-modules.sh b/.github/scripts/changed-modules.sh index a5932c32..7c156acc 100755 --- a/.github/scripts/changed-modules.sh +++ b/.github/scripts/changed-modules.sh @@ -33,13 +33,12 @@ function is_excluded() { # Find all go.mod files in the repository, building a list of all the available modules. # Do not include the root go.mod file. -for modFile in $(find "${ROOT_DIR}" -name "go.mod" -not -path "${ROOT_DIR}/go.mod" -not -path "${ROOT_DIR}/**/testdata/*"); do - # do not include the excluded modules - if is_excluded "$(basename "$(dirname "${modFile}")")"; then - continue +while IFS= read -r modFile; do + module_dir=$(basename "$(dirname "${modFile}")") || continue + if ! is_excluded "$module_dir"; then + modules+=("\"$module_dir\"") fi - modules+=("\"$(basename "$(dirname "${modFile}")")\"") -done +done < <(find "${ROOT_DIR}" -name "go.mod" -not -path "${ROOT_DIR}/go.mod" -not -path "${ROOT_DIR}/**/testdata/*") # sort modules array mapfile -t modules < <(printf '%s\n' "${modules[@]}" | sort)