"""Nur Push (kein Stage/Commit) - testet ob oauth2-Auth den Push ermoeglicht.""" from pathlib import Path from dulwich import porcelain REPO_PATH = str(Path(__file__).parent.parent) REMOTE_URL = "https://git.tech.rz.db.de/AndreKnie/project-audit.git" secrets = {} with open("project-audit/.secrets", "r", encoding="utf-8-sig") as f: for line in f: if "=" in line and not line.startswith("#"): k, v = line.strip().split("=", 1) secrets[k.strip()] = v.strip() token = secrets.get("GITLAB_TOKEN_AUDIT", "") print(f"Push mit oauth2-Auth (Token: ...{token[-4:]})") print(f"Repo: {REPO_PATH}") print(f"Remote: {REMOTE_URL}") print(f"Refspec: master -> master") print() try: porcelain.push( REPO_PATH, REMOTE_URL, refspecs=b"refs/heads/master:refs/heads/master", username="oauth2", password=token ) print("PUSH ERFOLGREICH!") except Exception as e: print(f"FEHLER: {e}")