From 8cde37b85ce4e7abf93af5c98a8210eeeb599b34 Mon Sep 17 00:00:00 2001 From: slyphax Date: Sun, 25 Oct 2026 10:25:55 +0100 Subject: [PATCH] Updater: Klon vor/auf anderem Branch ist kein Update mehr, Pull gezielt origin main --- src/editor/updater.gd | 17 ++++++++++++++++- tests/test_updater.gd | 9 +++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/editor/updater.gd b/src/editor/updater.gd index 19e80e7..172474f 100644 --- a/src/editor/updater.gd +++ b/src/editor/updater.gd @@ -160,9 +160,23 @@ static func check_update(git_exe: String, project_dir: String) -> Dictionary: "error": "Origin lieferte keinen Commit (nur Warnungen)."} if local == remote: return {"status": "up_to_date", "local": local, "remote": remote, "error": ""} + # Befund 25.10.: „Update verfügbar“ blieb nach dem Update stehen, weil nur + # HEAD != origin/main geprüft wurde. Steht der Klon auf einem anderen + # Branch oder VOR main (z. B. Feature-Branch), ist das KEIN Update: + # nur melden, wenn der Remote-Commit NICHT schon in HEAD steckt. + if remote_in_head(git_exe, project_dir, remote): + return {"status": "up_to_date", "local": local, "remote": remote, "error": ""} return {"status": "update_available", "local": local, "remote": remote, "error": ""} +## Ist `remote` schon Vorfahre von HEAD (Klon gleich oder VORAUS)? Unbekannter +## Commit (Exit 128) = noch nicht geholt = echtes Update → false. +static func remote_in_head(git_exe: String, project_dir: String, remote: String) -> bool: + var r := git_run(git_exe, project_dir, PackedStringArray([ + "merge-base", "--is-ancestor", remote, "HEAD"])) + return bool(r["ok"]) + + ## Aus der gemischten ls-remote-Ausgabe den Commit für `branch` lesen. ## WARUM: `git_run` mischt stdout+stderr, und der git-Client schreibt bei einer ## HTTP-Umleitung zuerst "warning: Umleitung nach ..." — die alte Fassung nahm @@ -246,7 +260,8 @@ const AUTO_STASH_MESSAGE := "auto: Selbst-Update" ## fürs Statuszeile-Fenster, leer wenn nichts besonderes passiert ist). static func pull(git_exe: String, project_dir: String) -> Dictionary: var stash_info := _stash_local_changes(git_exe, project_dir) - var r := git_run(git_exe, project_dir, PackedStringArray(["pull", "--ff-only"])) + # Gezielt origin/main ziehen (nicht den Upstream des aktuellen Branches). + var r := git_run(git_exe, project_dir, PackedStringArray(["pull", "--ff-only", "origin", BRANCH])) var errors: Array = [] var text := str(r["output"]).strip_edges() var info := "" diff --git a/tests/test_updater.gd b/tests/test_updater.gd index bc8dcbf..77a20fa 100644 --- a/tests/test_updater.gd +++ b/tests/test_updater.gd @@ -252,6 +252,15 @@ func _run_tests() -> void: var pulled := EditorUpdater.pull(git, work) _check(bool(pulled["ok"]), "pull --ff-only erfolgreich (v2 wird geladen)") _check(EditorUpdater.head_sha(git, work) == str(avail["remote"]), "nach Pull ist work auf v2") + # Befund 25.10.: Klon VOR origin/main (z. B. Feature-Branch) ist KEIN Update. + _git(work, ["config", "user.email", "t@example.invalid"]) + _git(work, ["config", "user.name", "Update-Test"]) + _write_file(work.path_join("lokal.txt"), "nur lokal\n") + _git(work, ["add", "lokal.txt"]) + _git(work, ["commit", "-m", "lokal voraus", "lokal.txt"]) + var ahead := EditorUpdater.check_update(git, work) + _check(str(ahead["status"]) == "up_to_date", "Klon VORAUS (Feature-Branch) → up_to_date, kein Dauer-Banner") + _git(work, ["reset", "--hard", "-q", str(avail["remote"])]) _git(work, ["remote", "set-url", "origin", "http://127.0.0.1:1/nicht-da.git"]) var dead_pull := EditorUpdater.pull(git, work) _check(not bool(dead_pull["ok"]), "pull gegen toten Origin schlägt fehl")