Skip to content

Commit 9e72163

Browse files
committed
feat: use associative arrays for package deduplication (matches design doc)
1 parent 5add89f commit 9e72163

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

.kokoro/system.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,19 @@ if [[ "$TRIGGER_ADHOC" == "true" ]]; then
304304
source ci/adhoc/adhoc_test_runner.sh
305305

306306
echo "Deduplicating packages..."
307-
# Portable deduplication avoiding 'declare -A' (compatible with older Bash)
308-
COMBINED=$(printf "%s\n" "${PACKAGES_TO_TEST[@]}" $ADHOC_PACKAGES | sort -u | grep -v '^$' || true)
309-
PACKAGES_TO_TEST=($COMBINED)
307+
# Deduplication using Associative Arrays (Requires Bash 4+)
308+
declare -A unique_packages
309+
for pkg in "${PACKAGES_TO_TEST[@]}"; do
310+
unique_packages["$pkg"]=1
311+
done
312+
for pkg in $ADHOC_PACKAGES; do
313+
unique_packages["$pkg"]=1
314+
done
315+
316+
# Remove empty string key if any
317+
unset 'unique_packages[""]'
318+
319+
PACKAGES_TO_TEST=("${!unique_packages[@]}")
310320

311321
echo "Combined packages to test: ${PACKAGES_TO_TEST[*]}"
312322
fi

0 commit comments

Comments
 (0)