From 44b4467026bfb482af952cdfcb74a82366ee1156 Mon Sep 17 00:00:00 2001 From: Jason Greathouse Date: Wed, 22 Feb 2023 15:35:55 -0600 Subject: [PATCH] strip trailing - with sed (#26) --- util/metadata.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/metadata.sh b/util/metadata.sh index 73607b2..7628dbb 100755 --- a/util/metadata.sh +++ b/util/metadata.sh @@ -118,10 +118,10 @@ EOF if [[ ${#normalized_branch} -gt ${cutoff} ]] then - cut_branch=$(echo "${normalized_branch}" | cut -c -${cutoff}) - echo "Your branch name ${normalized_branch} + metadata exceeds the maximum length for K8s identifiers, truncating to ${cut_branch}" # cut branch should not end in - trim any dashes from the end. - normalized_branch="${cut_branch%%*(-)}" + cut_branch=$(echo "${normalized_branch}" | cut -c -${cutoff} | sed -e 's!-*$!!') + echo "Your branch name ${normalized_branch} + metadata exceeds the maximum length for K8s identifiers, truncating to ${cut_branch}" + normalized_branch="${cut_branch}" fi echo "Before: '${branch}'"