src/dlw/git_ops.py aktualisiert

This commit is contained in:
Kim Diallo 2026-01-03 02:46:43 +01:00
parent 33c4f6af28
commit 8b456a57a0
1 changed files with 6 additions and 20 deletions

View File

@ -1,26 +1,12 @@
from git import Repo, exc
import os
REPO_PATH = os.getcwd()
def initialize_repo():
try:
return Repo(REPO_PATH)
except exc.InvalidGitRepositoryError:
return None
def commit_and_push_article(article_path, download_paths, title):
repo = initialize_repo()
if not repo:
return False, "Kein Git-Repository gefunden."
try:
files_to_add = [article_path] + download_paths
repo.index.add(files_to_add)
repo.index.commit(f"FEAT: Neuer Artikel - {title}")
origin = repo.remotes.origin
origin.push()
return True, "Erfolgreich gepusht!"
repo = Repo(os.getcwd())
repo.index.add([article_path] + download_paths)
repo.index.commit(f"FEAT: {title}")
repo.remotes.origin.push()
return True, "Gepusht zu Forgejo!"
except Exception as e:
return False, f"Fehler: {str(e)}"
return False, str(e)