Lokal abweichenden Ablageort der Plugin-Klone unterstuetzen (#6)

hallo.py, setup_workspace.py und link_qgis_profile.py gingen bisher fest
davon aus, dass die Repos aus workspace.toml direkte Unterordner von
Projektwissen sind. Eine optionale, nicht versionierte workspace.local.toml
mit [workspace] repos_root = "..." kann das jetzt lokal ueberschreiben, z. B.
wenn die Klone zusaetzlich unter einem separaten src-Ordner liegen und von
dort in mehrere QGIS-Profile verlinkt werden. Ohne diese Datei bleibt das
Verhalten fuer alle unveraendert.
This commit is contained in:
Michael Otto
2026-09-14 11:36:55 +02:00
parent 3d1e9b4b3d
commit 85a34e4d1d
3 changed files with 54 additions and 4 deletions
+17 -2
View File
@@ -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)