Bahn: aisupport, Analyse-O2C-C2S, awesome-bahn-mcp-servers, beam-mcp,
Confluence_Bot, db-planet-mcp-server, O2C-Harness, project-audit,
Projekt-KIQ-HP, teamlandkarte-mcp
Dhive: Jury-Voting
Privat: CV, NoteGraph (NOTE: NoteGraph needs complete redo after consolidation)
Shared: AI-Orchestrator, OrgMyLife, power_skills_and_more
Shared/references: symphony (read-only)
Bahn repos remain available as independent remotes - this monorepo
pulls them in via subtree, the originals are untouched.
103 lines
3.1 KiB
Python
103 lines
3.1 KiB
Python
"""
|
|
Git-Init fuer project-audit (nutzt dulwich statt git binary)
|
|
Initialisiert Repo, staged alle Dateien, erstellt Initial-Commit.
|
|
"""
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# dulwich imports
|
|
from dulwich.repo import Repo
|
|
from dulwich.objects import Blob, Tree, Commit
|
|
from dulwich import porcelain
|
|
|
|
REPO_PATH = Path(__file__).parent.parent # project-audit/
|
|
REMOTE_URL = "https://git.tech.rz.db.de/AndreKnie/project-audit.git"
|
|
|
|
|
|
def main():
|
|
print("=== Git Init: project-audit ===")
|
|
print(f" Pfad: {REPO_PATH}")
|
|
|
|
# Repo initialisieren
|
|
if (REPO_PATH / ".git").exists():
|
|
print(" Repo existiert bereits.")
|
|
repo = Repo(str(REPO_PATH))
|
|
else:
|
|
print(" Initialisiere neues Repo...")
|
|
repo = Repo.init(str(REPO_PATH))
|
|
print(" OK")
|
|
|
|
# .gitignore lesen fuer Ausschluesse
|
|
ignore_patterns = []
|
|
gitignore_path = REPO_PATH / ".gitignore"
|
|
if gitignore_path.exists():
|
|
with open(gitignore_path, "r") as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
if line and not line.startswith("#"):
|
|
ignore_patterns.append(line)
|
|
|
|
def should_ignore(rel_path):
|
|
"""Einfacher .gitignore Check."""
|
|
rel_str = str(rel_path).replace("\\", "/")
|
|
for pattern in ignore_patterns:
|
|
pattern_clean = pattern.strip("/")
|
|
if pattern_clean in rel_str:
|
|
return True
|
|
if rel_str.endswith(pattern_clean):
|
|
return True
|
|
return False
|
|
|
|
# Alle Dateien stagen
|
|
print(" Stage Dateien...")
|
|
staged = 0
|
|
for root, dirs, files in os.walk(REPO_PATH):
|
|
# .git Verzeichnis ueberspringen
|
|
if ".git" in root:
|
|
continue
|
|
for fname in files:
|
|
full_path = Path(root) / fname
|
|
rel_path = full_path.relative_to(REPO_PATH)
|
|
if should_ignore(rel_path):
|
|
continue
|
|
try:
|
|
porcelain.add(str(REPO_PATH), paths=[str(rel_path)])
|
|
staged += 1
|
|
except Exception:
|
|
pass
|
|
|
|
print(f" {staged} Dateien gestaged")
|
|
|
|
# Commit
|
|
print(" Erstelle Initial-Commit...")
|
|
try:
|
|
porcelain.commit(
|
|
str(REPO_PATH),
|
|
message=b"Initial: pathOS Portfolio-Audit (4 Tage Analyse)",
|
|
author=b"Andre Knie <andre.knie@deutschebahn.com>",
|
|
committer=b"Andre Knie <andre.knie@deutschebahn.com>"
|
|
)
|
|
print(" Commit erstellt!")
|
|
except Exception as e:
|
|
print(f" Commit-Fehler: {e}")
|
|
|
|
# Remote hinzufuegen
|
|
print(f" Remote: {REMOTE_URL}")
|
|
try:
|
|
config = repo.get_config()
|
|
config.set((b"remote", b"origin"), b"url", REMOTE_URL.encode())
|
|
config.set((b"remote", b"origin"), b"fetch", b"+refs/heads/*:refs/remotes/origin/*")
|
|
config.write_to_path()
|
|
print(" Remote 'origin' konfiguriert")
|
|
except Exception as e:
|
|
print(f" Remote-Fehler: {e}")
|
|
|
|
print("\n FERTIG!")
|
|
print(f" Push spaeter mit: python -m dulwich push {REMOTE_URL}")
|
|
print(f" Oder wenn git installiert: git push -u origin main")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|