]> juplo.de Git - demos/kafka/training/commitdiff
lib.sh: reset_branches_to_remote zeigt nur tatsächlich geänderte Branches
authorKai Moritz <kai.milan.moritz@googlemail.com>
Sun, 31 May 2026 19:53:23 +0000 (19:53 +0000)
committerKai Moritz <kai.milan.moritz@googlemail.com>
Sun, 31 May 2026 19:53:23 +0000 (19:53 +0000)
Branches, bei denen lokaler Stand und origin/<branch> bereits identisch
sind, werden ohne Ausgabe übersprungen. Profitiert auch reset.sh.

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

diff --git a/lib.sh b/lib.sh
index c540626cb36072424aadd5acbf5fe1d1af7bb896..31bd8472198d8dae5683a73b6af5b5b8b9e316e9 100755 (executable)
--- a/lib.sh
+++ b/lib.sh
@@ -37,8 +37,11 @@ find_common_tag_suffixes() {
 # Erwartet, dass origin aktuell ist — ggf. vorher git fetch origin aufrufen.
 # Kehrt am Ende zu scripting zurück.
 reset_branches_to_remote() {
-  local branch
+  local branch local_hash remote_hash
   for branch in "${BRANCH_NAMES[@]}"; do
+    local_hash=$(git rev-parse "$branch" 2>/dev/null) || continue
+    remote_hash=$(git rev-parse "refs/remotes/origin/$branch" 2>/dev/null) || continue
+    [ "$local_hash" != "$remote_hash" ] || continue
     echo "  $branch"
     git checkout -q "$branch"
     git reset -q --hard "origin/$branch"