From 4a4a7a0722f0f8388b589b767def6bc82e0f5e64 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 12 Jun 2026 16:54:20 +0000 Subject: [PATCH] =?utf8?q?feat(push.sh):=20--tag=20und=20--force=20f=C3=BC?= =?utf8?q?r=20explizites=20Tagging=20beim=20Push?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Neu: --tag erstellt -- 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 --- push.sh | 63 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/push.sh b/push.sh index 6d6dd80b..9ef0a5bf 100755 --- 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 ] [--force] [--help]" echo "" - echo " --help Diese Hilfe anzeigen" - exit 0 - ;; - *) echo "Unbekannter Parameter: $arg" >&2; exit 1 ;; + echo " --tag Taggt alle Branches als -- 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 -- 2.39.5