]> juplo.de Git - demos/kafka/training/commitdiff
Skripte: Best Practices -- Timestamp einmalig, Schleifen-Duplizierung entfernt, Quoting
authorKai Moritz <kai.milan.moritz@googlemail.com>
Sun, 31 May 2026 09:28:06 +0000 (09:28 +0000)
committerKai Moritz <kai.milan.moritz@googlemail.com>
Sun, 31 May 2026 09:28:06 +0000 (09:28 +0000)
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 <noreply@anthropic.com>
build.sh
push.sh
reset.sh

index 526700fabba41d6bad38b59f1aa5a767a836248f..f95b6440b243ce31d0aa98256ff3024a18ebe06b 100755 (executable)
--- 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 ebcf19d3eb788871b29d6f0ec1c433e525429844..c10aebf30a7597cdb4a3d5d74caa1c4fd6f4d77c 100755 (executable)
--- 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
index ed2ab0f64c4cfc2ee7d5ea11d99955982a7bbd02..cffbfd55185a66828cf74fb0075e982c98386752 100755 (executable)
--- 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