From 36f96d2cd892fb97f7227870299d15a688633410 Mon Sep 17 00:00:00 2001 From: Adrien Date: Mon, 28 Oct 2024 15:05:47 +0100 Subject: [PATCH] feat: support for comma separated list of commits & deliverables --- entrypoint.sh | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 731b690..44203b8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -22,10 +22,32 @@ while getopts ":t:v:d:c:s:i:" opt; do v) version=$(trim "${OPTARG}") ;; d) - mapfile -t deliverables < <(trim "${OPTARG}") + deliverables=() + + if [[ "${OPTARG}" =~ ^([^,]+,)+[^,]+$ ]]; then # Support comma separated list of deliverables + IFS=',' read -r -a raw_deliverables <<< "${OPTARG}" + else + mapfile -t raw_deliverables < <(echo "${OPTARG}") # Support Newline-separated list of deliverables + fi + + for deliverable in "${raw_deliverables[@]}"; do + trimmed_deliverable=$(trim "$deliverable") + deliverables+=("$trimmed_deliverable") + done ;; c) - mapfile -t commits < <(trim "${OPTARG}") + commits=() + + if [[ "${OPTARG}" =~ ^([^,]+,)+[^,]+$ ]]; then # Support comma separated list of commits + IFS=',' read -r -a raw_commits <<< "${OPTARG}" + else + mapfile -t raw_commits < <(echo "${OPTARG}") # Support Newline-separated list of commits + fi + + for commit in "${raw_commits[@]}"; do + trimmed_commit=$(trim "$commit") + commits+=("$trimmed_commit") + done ;; s) status=$(trim "${OPTARG}") ;;