src/dlw/git_ops.py aktualisiert
This commit is contained in:
parent
33c4f6af28
commit
8b456a57a0
|
|
@ -1,26 +1,12 @@
|
||||||
from git import Repo, exc
|
from git import Repo, exc
|
||||||
import os
|
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):
|
def commit_and_push_article(article_path, download_paths, title):
|
||||||
repo = initialize_repo()
|
|
||||||
if not repo:
|
|
||||||
return False, "Kein Git-Repository gefunden."
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
files_to_add = [article_path] + download_paths
|
repo = Repo(os.getcwd())
|
||||||
repo.index.add(files_to_add)
|
repo.index.add([article_path] + download_paths)
|
||||||
repo.index.commit(f"FEAT: Neuer Artikel - {title}")
|
repo.index.commit(f"FEAT: {title}")
|
||||||
|
repo.remotes.origin.push()
|
||||||
origin = repo.remotes.origin
|
return True, "Gepusht zu Forgejo!"
|
||||||
origin.push()
|
|
||||||
return True, "Erfolgreich gepusht!"
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False, f"Fehler: {str(e)}"
|
return False, str(e)
|
||||||
Loading…
Reference in New Issue