From 4c911716ba9d4a12130ec1ad1c5d63abfd53d4af Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 31 May 2026 09:28:06 +0000 Subject: [PATCH] Skripte: Best Practices -- Timestamp einmalig, Schleifen-Duplizierung entfernt, Quoting MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit push.sh: TIMESTAMP einmal vor der Schleife berechnen (alle Branches eines Laufs teilen denselben Zeitstempel); Variablen gequotet. reset.sh: Duplizierte Schleife zu einer einzigen zusammengeführt; ref-Variable bestimmt den Ziel-Stand; Variablen gequotet. build.sh: =~ (Regex) durch == mit Glob-Pattern ersetzt (*--vorlage, grundlagen/*). Co-Authored-By: Claude Sonnet 4.6 --- build.sh | 4 ++-- push.sh | 11 ++++++----- reset.sh | 32 +++++++++++++------------------- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/build.sh b/build.sh index 526700fa..f95b6440 100755 --- a/build.sh +++ b/build.sh @@ -12,7 +12,7 @@ for i in $BRANCHES; do declare -n branch=${i} git checkout "$branch" - if [[ "$branch" =~ "--vorlage" ]]; then + if [[ "$branch" == *--vorlage ]]; then echo -e "\nIgnoriere Vorlage: $branch\n" continue fi @@ -22,7 +22,7 @@ for i in $BRANCHES; do mvn clean install if $PUBLISH; then echo -e "\nVeröffentliche Docker-Image für $branch" - if [[ "$branch" =~ "grundlagen/" ]]; then + if [[ "$branch" == grundlagen/* ]]; then mvn jib:build else mvn spring-boot:build-image -Dspring-boot.build-image.publish=true diff --git a/push.sh b/push.sh index ebcf19d3..c10aebf3 100755 --- a/push.sh +++ b/push.sh @@ -3,11 +3,12 @@ set -e source branches.sh -for i in grundlagen__docker $BRANCHES; -do +TIMESTAMP=$(date +'%Y-%m-%d--%H-%M-%S') + +for i in grundlagen__docker $BRANCHES; do declare -n branch=${i} echo -e "\nPushing $branch over origin/$branch" - git tag -f ${branch}--BACKUP-ORIGIN--$(date +'%Y-%m-%d--%H-%M-%S') origin/$branch || echo "origin/$branch existiert (noch) nicht!" - git tag -f ${branch}--BACKUP-ORIGIN--LAST origin/$branch || echo "origin/$branch existiert (noch) nicht!" - git push --force origin $branch:$branch + git tag -f "${branch}--BACKUP-ORIGIN--${TIMESTAMP}" "origin/$branch" || echo "origin/$branch existiert (noch) nicht!" + git tag -f "${branch}--BACKUP-ORIGIN--LAST" "origin/$branch" || echo "origin/$branch existiert (noch) nicht!" + git push --force origin "$branch:$branch" done diff --git a/reset.sh b/reset.sh index ed2ab0f6..cffbfd55 100755 --- a/reset.sh +++ b/reset.sh @@ -3,24 +3,18 @@ set -e source branches.sh -if [ "$1" == "" ] -then - echo "No Tag-Prefix specified: Resetting to remote branches" - for i in grundlagen__docker $BRANCHES - do - declare -n branch=${i} - echo -e "\nResetting $branch to origin/$branch\n\n" - git checkout $branch - git reset --hard origin/$branch - done -else - for i in grundlagen__docker $BRANCHES - do - declare -n branch=${i} - echo -e "\nResetting $branch to tag ${branch}--$1\n" - git checkout $branch - git reset --hard ${branch}--$1 - done -fi +[ "$1" = "" ] && echo "No Tag-Prefix specified: Resetting to remote branches" + +for i in grundlagen__docker $BRANCHES; do + declare -n branch=${i} + if [ "$1" = "" ]; then + ref="origin/$branch" + else + ref="${branch}--$1" + fi + echo -e "\nResetting $branch to $ref" + git checkout "$branch" + git reset --hard "$ref" +done git checkout scripting -- 2.39.5