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
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
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