From 076414b76e6a1078ccda50ae9cc21a7a6108024c Mon Sep 17 00:00:00 2001 From: Mark Ridgwell <273118822+dnyw4l3n13@users.noreply.github.com> Date: Sat, 6 Jun 2026 10:22:35 +0100 Subject: [PATCH] fix: replace raw echo with output helpers in git/missing-release-branches Replace bare echo calls with die/info/success helpers for consistent, coloured output and proper error-exit behaviour on failure. Prompt: Work on issue #646 in credfeto/scripts. Replace raw echo with output helpers (die, info, success) in git/missing-release-branches. Closes #646 --- CHANGELOG.md | 1 + git/missing-release-branches | 39 ++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe8da2e8..fc981183 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Please ADD ALL Changes to the UNRELEASED SECTION and not a specific release - Replace raw echo with standard output helpers (die/info/success) in github/cancel-workflows - Replace raw echo with standard output helpers (die/info/success) in git/update-repos-personal - GEOIP - Updated GEOIP DB from MaxMind (2026-06-06) +- Replace raw echo with output helpers (die, info, success) in git/missing-release-branches ### Deprecated ### Removed ### Deployment Changes diff --git a/git/missing-release-branches b/git/missing-release-branches index 5be43dac..8bea2e7d 100755 --- a/git/missing-release-branches +++ b/git/missing-release-branches @@ -1,32 +1,49 @@ #! /bin/bash + +die() { + printf '\n\033[31m✗\033[0m %s\n' "$*" >&2 + exit 1 +} + +success() { + printf '\n\033[32m✓\033[0m %s\n' "$*" +} + +info() { + printf '\n\033[32m→\033[0m %s\n' "$*" +} + REGEX_CHANGELOG="^([0-9a-zA-Z]*)\s.*Changelog\sfor\s([0-9]*\.[0-9]*\.[0-9]*)$" matchingBranch() { CHANGE_RELEASE=$1 SEARCH_BRANCH="origin/release/$CHANGE_RELEASE" git branch --remote | while read -r BRANCH; do - #echo "SRC: $BRANCH" if [[ "$BRANCH" = "$SEARCH_BRANCH" ]]; then echo "Y" break fi done } - -git log --oneline | while read -r CHANGE; do + +if git log --oneline | while read -r CHANGE; do if [[ $CHANGE =~ $REGEX_CHANGELOG ]]; then CHANGE_HASH="${BASH_REMATCH[1]}" CHANGE_RELEASE="${BASH_REMATCH[2]}" - FOUND=$(matchingBranch "$CHANGE_RELEASE") + FOUND=$(matchingBranch "$CHANGE_RELEASE") if [ "$FOUND" = "Y" ]; then - echo "* Found Release $CHANGE_RELEASE at in release/$CHANGE_RELEASE at $CHANGE_HASH" - else - echo "- Missing Release $CHANGE_RELEASE in $CHANGE_HASH" + info "Found Release $CHANGE_RELEASE in release/$CHANGE_RELEASE at $CHANGE_HASH" + else + info "Missing Release $CHANGE_RELEASE in $CHANGE_HASH" git checkout "$CHANGE_HASH" && git checkout -b "release/$CHANGE_RELEASE" && git push - git switch main || echo "Switching to Main" - echo "+++ Created branch release/$CHANGE_RELEASE" + git switch main || true + success "Created branch release/$CHANGE_RELEASE" fi - + fi -done && echo "OK" || echo "Failed" +done; then + success "OK" +else + die "Failed" +fi