]> juplo.de Git - demos/kafka/training/commitdiff
feat(push.sh): --tag und --force für explizites Tagging beim Push
authorKai Moritz <kai.milan.moritz@googlemail.com>
Fri, 12 Jun 2026 16:54:20 +0000 (16:54 +0000)
committerKai Moritz <kai.milan.moritz@googlemail.com>
Fri, 12 Jun 2026 16:54:20 +0000 (16:54 +0000)
Neu: --tag <suffix> erstellt <branch>--<suffix> für alle Branches
und pusht die Tags nach den Branches. Mit --force werden bestehende
Tags lokal (-f) und remote (--force) überschrieben.

Die bisherige automatische Suche nach gemeinsamen lokalen Tags und
deren Push entfällt. Das Backup-Tagging für überschriebene Remote-
Stände (TIMESTAMP) bleibt unverändert.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
push.sh

diff --git a/push.sh b/push.sh
index 6d6dd80b2785258af86fefb766b46f9d33d9aff6..9ef0a5bf340ba2fa60b25865fbedfa70a6305937 100755 (executable)
--- a/push.sh
+++ b/push.sh
@@ -3,21 +3,27 @@ set -e
 
 source lib.sh
 
-for arg in "$@"; do
-  case "$arg" in
+TAG_SUFFIX=""
+FORCE=false
+while [ $# -gt 0 ]; do
+  case "$1" in
+    --tag)
+      [ -n "$2" ] || { echo "Fehler: --tag erfordert einen Wert" >&2; exit 1; }
+      TAG_SUFFIX="$2"; shift 2 ;;
+    --force)
+      FORCE=true; shift ;;
     --help)
       echo "Force-pusht alle Branches zu origin."
       echo "Prüft vorab, ob umzuschreibende Remote-Stände bereits gesichert sind;"
       echo "fehlt ein Tag, werden TIMESTAMP-Backup-Tags für alle Remote-Stände im Remote angelegt."
-      echo "Gemeinsame lokale Tag-Suffixe (z.B. --claude-5 für alle Branches) werden ebenfalls gepusht,"
-      echo "sofern noch nicht im Remote vorhanden."
       echo ""
-      echo "Verwendung: ./push.sh [--help]"
+      echo "Verwendung: ./push.sh [--tag <suffix>] [--force] [--help]"
       echo ""
-      echo "  --help   Diese Hilfe anzeigen"
-      exit 0
-      ;;
-    *) echo "Unbekannter Parameter: $arg" >&2; exit 1 ;;
+      echo "  --tag <suffix>   Taggt alle Branches als <branch>--<suffix> und pusht die Tags"
+      echo "  --force          Überschreibt bestehende Tags (nur wirksam mit --tag)"
+      echo "  --help           Diese Hilfe anzeigen"
+      exit 0 ;;
+    *) echo "Unbekannter Parameter: $1" >&2; exit 1 ;;
   esac
 done
 
@@ -56,8 +62,20 @@ if [ "$need_timestamp_backup" = true ]; then
   done
 fi
 
-# Step 3: Find common local tag suffixes (suffix S where every branch B has local tag B--S)
-mapfile -t common_suffixes < <(find_common_tag_suffixes 2>/dev/null || true)
+# Step 3: Create local tags if --tag given
+if [ -n "$TAG_SUFFIX" ]; then
+  echo -e "\nErzeuge Tags mit Suffix '$TAG_SUFFIX'..."
+  for branch in "${BRANCH_NAMES[@]}"; do
+    git rev-parse --verify "$branch" &>/dev/null || continue
+    tag_name="${branch}--${TAG_SUFFIX}"
+    if $FORCE; then
+      git tag -f "$tag_name" "$branch"
+    else
+      git tag "$tag_name" "$branch"
+    fi
+    echo "  $tag_name"
+  done
+fi
 
 # Step 4: Push all branches
 for branch in "${BRANCH_NAMES[@]}"; do
@@ -65,16 +83,17 @@ for branch in "${BRANCH_NAMES[@]}"; do
   git push --force origin "$branch:$branch"
 done
 
-# Step 5: Push common local tags that are not yet in the remote
-if [ ${#common_suffixes[@]} -gt 0 ]; then
-  echo ""
-  for suffix in "${common_suffixes[@]}"; do
-    for branch in "${BRANCH_NAMES[@]}"; do
-      tag_name="${branch}--${suffix}"
-      if ! echo "$remote_tags" | grep -qF "refs/tags/${tag_name}"; then
-        echo "Pushing tag: $tag_name"
-        git push origin "$tag_name"
-      fi
-    done
+# Step 5: Push tags if --tag given
+if [ -n "$TAG_SUFFIX" ]; then
+  echo -e "\nPushe Tags mit Suffix '$TAG_SUFFIX'..."
+  for branch in "${BRANCH_NAMES[@]}"; do
+    git rev-parse --verify "refs/tags/${branch}--${TAG_SUFFIX}" &>/dev/null || continue
+    tag_name="${branch}--${TAG_SUFFIX}"
+    if $FORCE; then
+      git push --force origin "$tag_name"
+    else
+      git push origin "$tag_name"
+    fi
+    echo "  $tag_name"
   done
 fi