diff --git a/scripts/hallo.py b/scripts/hallo.py index 283b539..d537589 100644 --- a/scripts/hallo.py +++ b/scripts/hallo.py @@ -45,6 +45,26 @@ from pathlib import Path ROOT = Path(__file__).resolve().parents[1] MANIFEST = ROOT / "workspace.toml" +LOKALE_ÜBERSCHREIBUNG = ROOT / "workspace.local.toml" + + +def repos_root() -> Path: + """Ordner, unter dem die Plugin-/Daten-Repositories liegen. + + Standard: ROOT selbst (Repos als direkte Unterordner, wie in workspace.toml + dokumentiert). Wer die Klone woanders liegen hat (z. B. ein separater + src-Ordner, der zusätzlich ins QGIS-Profil verlinkt wird), kann das lokal + und nicht versioniert in workspace.local.toml überschreiben: + + [workspace] + repos_root = "C:/Projekte/QGIS/src/dev" + """ + if not LOKALE_ÜBERSCHREIBUNG.is_file(): + return ROOT + with LOKALE_ÜBERSCHREIBUNG.open("rb") as f: + lokal = tomllib.load(f) + pfad = lokal.get("workspace", {}).get("repos_root") + return Path(pfad).expanduser() if pfad else ROOT BREITE = 100 # Zielbreite der Tabelle (lesbar im 100-Zeichen-Terminal) FETCH_TIMEOUT = 60 # Sekunden je git fetch, damit ein hängender Server nicht blockiert @@ -348,13 +368,16 @@ def main() -> int: if wurzel_ist_repo and gewuenscht(ROOT.name): befunde.append(Befund(name=ROOT.name, kanal=manifest.get("workspace", {}).get("branch", ""), pfad=ROOT, ist_wurzel=True)) - befunde += [Befund(name=r["name"], kanal=r["branch"], pfad=ROOT / r["name"]) + rroot = repos_root() + befunde += [Befund(name=r["name"], kanal=r["branch"], pfad=rroot / r["name"]) for r in repos if gewuenscht(r["name"])] modus = ("ohne Netz – kein fetch, kein Pull" if args.ohne_netz else "nur prüfen – fetch, kein Pull" if args.nur_pruefen else "fetch und fast-forward-Pull") print(f"Hallo. Workspace: {ROOT}") + if rroot != ROOT: + print(f"Repositories liegen laut workspace.local.toml unter: {rroot}") print(f"Modus: {modus} | Repositories: {len(befunde)}") if not wurzel_ist_repo and gewuenscht(ROOT.name): print(f"Hinweis: '{ROOT.name}' selbst ist noch kein Git-Repository – geprüft werden nur die Klone.") diff --git a/scripts/link_qgis_profile.py b/scripts/link_qgis_profile.py index 4392f01..b970343 100644 --- a/scripts/link_qgis_profile.py +++ b/scripts/link_qgis_profile.py @@ -24,9 +24,20 @@ import tomllib from pathlib import Path ROOT = Path(__file__).resolve().parents[1] +LOKALE_ÜBERSCHREIBUNG = ROOT / "workspace.local.toml" ROLLEN_MIT_PLUGIN = {"plattform", "fachplugin", "geruest"} +def repos_root() -> Path: + """Ordner der Plugin-/Daten-Klone, siehe workspace.local.toml (nicht versioniert).""" + if not LOKALE_ÜBERSCHREIBUNG.is_file(): + return ROOT + with LOKALE_ÜBERSCHREIBUNG.open("rb") as f: + lokal = tomllib.load(f) + pfad = lokal.get("workspace", {}).get("repos_root") + return Path(pfad).expanduser() if pfad else ROOT + + def profil_plugin_ordner(profil: str) -> Path: if sys.platform.startswith("win"): basis = Path(os.environ.get("APPDATA", Path.home() / "AppData" / "Roaming")) @@ -99,8 +110,9 @@ def main() -> int: print(" (existiert noch nicht – QGIS mit diesem Profil einmal starten oder --pfad prüfen)") rc = 0 + rroot = repos_root() for paket in gewuenscht: - quelle = ROOT / repos[paket]["name"] + quelle = rroot / repos[paket]["name"] ziel = plugin_ordner / paket if not (quelle / "__init__.py").is_file(): print(f"[{paket}] übersprungen: {quelle.name} enthält kein Plugin (__init__.py fehlt)") diff --git a/scripts/setup_workspace.py b/scripts/setup_workspace.py index 7d7b09a..7346f79 100644 --- a/scripts/setup_workspace.py +++ b/scripts/setup_workspace.py @@ -24,6 +24,17 @@ import tomllib from pathlib import Path ROOT = Path(__file__).resolve().parents[1] +LOKALE_ÜBERSCHREIBUNG = ROOT / "workspace.local.toml" + + +def repos_root() -> Path: + """Ordner für die Plugin-/Daten-Klone, siehe workspace.local.toml (nicht versioniert).""" + if not LOKALE_ÜBERSCHREIBUNG.is_file(): + return ROOT + with LOKALE_ÜBERSCHREIBUNG.open("rb") as f: + lokal = tomllib.load(f) + pfad = lokal.get("workspace", {}).get("repos_root") + return Path(pfad).expanduser() if pfad else ROOT def git(*args: str, cwd: Path) -> tuple[int, str]: @@ -78,13 +89,17 @@ def main() -> int: manifest = tomllib.load(f) ws = manifest["workspace"] basis_url = f"{ws['gitea']}/{ws['org']}" + rroot = repos_root() print(f"Workspace: {ROOT}\nGitea: {basis_url}\n") + if rroot != ROOT: + print(f"Repositories liegen laut workspace.local.toml unter: {rroot}\n") + rroot.mkdir(parents=True, exist_ok=True) for repo in manifest["repos"]: name, branch = repo["name"], repo["branch"] - pfad = ROOT / name + pfad = rroot / name if not (pfad / ".git").is_dir(): print(f"[{name}] klone Branch {branch} ...") - rc, out = git("clone", "--branch", branch, f"{basis_url}/{name}.git", name, cwd=ROOT) + rc, out = git("clone", "--branch", branch, f"{basis_url}/{name}.git", name, cwd=rroot) print(" " + ("ok" if rc == 0 else f"FEHLER: {out}")) continue git("fetch", "--quiet", "--prune", cwd=pfad)