[2f488f42] Implement: Atomarer 'fertig' Befehl in dev_session.py mit automatischer Notion-Aktualisierung und Git-Operationen.

This commit is contained in:
2026-01-27 10:11:39 +00:00
parent c2b1c3d374
commit d418f48481
2 changed files with 72 additions and 13 deletions

View File

@@ -478,6 +478,34 @@ def generate_git_summary() -> Tuple[str, str]:
print(f"❌ FEHLER beim Generieren der Git-Zusammenfassung: {e}")
return "", ""
def git_push_with_retry() -> bool:
"""Versucht, Änderungen zu pushen, und führt bei einem non-fast-forward-Fehler einen Rebase und erneuten Push durch."""
print("\n--- Führe git push aus ---")
try:
subprocess.run(["git", "push"], check=True)
print("✅ Git push erfolgreich.")
return True
except subprocess.CalledProcessError as e:
if "non-fast-forward" in e.stderr.decode("utf-8"):
print("⚠️ Git push abgelehnt (non-fast-forward). Versuche git pull --rebase und erneuten Push...")
try:
subprocess.run(["git", "pull", "--rebase"], check=True)
print("✅ Git pull --rebase erfolgreich. Versuche erneuten Push...")
subprocess.run(["git", "push"], check=True)
print("✅ Git push nach Rebase erfolgreich.")
return True
except subprocess.CalledProcessError as pull_e:
print(f"❌ FEHLER bei git pull --rebase oder erneutem Push: {pull_e}")
print("Bitte löse Konflikte manuell und pushe dann.")
return False
else:
print(f"❌ FEHLER bei git push: {e}")
return False
except Exception as e:
print(f"❌ Unerwarteter Fehler bei git push: {e}")
return False
# --- Report Status to Notion ---
def report_status_to_notion(
@@ -576,8 +604,8 @@ def report_status_to_notion(
except ValueError:
print("Ungültige Eingabe. Bitte eine Zahl eingeben.")
else:
print("Warnung: Konnte Status-Optionen nicht abrufen. Bitte Status manuell eingeben.")
actual_status = input("Bitte gib den neuen Status manuell ein: ")
print("❌ FEHLER: Konnte Status-Optionen nicht abrufen. Abbruch des Berichts.")
return
if not actual_status:
print("❌ FEHLER: Kein Status festgelegt. Abbruch des Berichts.")
@@ -656,6 +684,26 @@ def report_status_to_notion(
status_payload = {"Status": {"status": {"name": actual_status}}}
update_notion_task_property(token, task_id, status_payload)
# --- Git Operationen ---
print("\n--- Führe Git-Operationen aus ---")
try:
subprocess.run(["git", "add", "."], check=True)
print("✅ Alle Änderungen gestaged (git add .).")
# Commit-Nachricht erstellen
commit_subject = actual_summary.splitlines()[0] if actual_summary else "Notion Status Update"
commit_message = f"[{task_id.split('-')[0]}] {commit_subject}\n\n{{actual_summary}}"
subprocess.run(["git", "commit", "-m", commit_message], check=True)
print("✅ Git commit erfolgreich.")
git_push_with_retry()
except subprocess.CalledProcessError as e:
print(f"❌ FEHLER bei Git-Operationen: {e}")
except Exception as e:
print(f"❌ Unerwarteter Fehler bei Git-Operationen: {e}")
except (FileNotFoundError, json.JSONDecodeError) as e:
print(f"❌ FEHLER beim Lesen der Session-Informationen für Statusbericht: {e}")
except Exception as e: