🚀 Initialer Commit: Gitea Sync AI Service mit Docker + OpenWebUI-Vorbereitung
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def clone_repo(repo_url: str, target_dir: Path, token: str = None):
|
||||
"""Klont ein Repository in den Zielordner."""
|
||||
if not target_dir.exists():
|
||||
target_dir.mkdir(parents=True)
|
||||
|
||||
# URL mit Token (falls nötig)
|
||||
if token and "@" not in repo_url:
|
||||
repo_url = repo_url.replace("https://", f"https://{token}@")
|
||||
|
||||
result = subprocess.run(
|
||||
["git", "clone", repo_url, str(target_dir)],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
|
||||
return {"success": result.returncode == 0, "output": result.stdout, "error": result.stderr}
|
||||
|
||||
|
||||
def push_changes(repo_path: Path, message: str = "Update 🧠"):
|
||||
"""Pusht lokale Änderungen ins Repository."""
|
||||
result = subprocess.run(
|
||||
["git", "add", "."], cwd=repo_path, capture_output=True, text=True
|
||||
)
|
||||
|
||||
if result.returncode != 0:
|
||||
return {"success": False, "error": f"git add fehlgeschlagen: {result.stderr}"}
|
||||
|
||||
result = subprocess.run(
|
||||
["git", "commit", "-m", message], cwd=repo_path, capture_output=True, text=True
|
||||
)
|
||||
|
||||
if result.returncode != 0 and "nothing to commit" not in result.stderr.lower():
|
||||
return {"success": False, "error": f"Commit fehlgeschlagen: {result.stderr}"}
|
||||
|
||||
result = subprocess.run(
|
||||
["git", "push"], cwd=repo_path, capture_output=True, text=True
|
||||
)
|
||||
|
||||
return {"success": result.returncode == 0, "output": result.stdout}
|
||||
Reference in New Issue
Block a user