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:
+24
-1
@@ -45,6 +45,26 @@ from pathlib import Path
|
|||||||
|
|
||||||
ROOT = Path(__file__).resolve().parents[1]
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
MANIFEST = ROOT / "workspace.toml"
|
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)
|
BREITE = 100 # Zielbreite der Tabelle (lesbar im 100-Zeichen-Terminal)
|
||||||
FETCH_TIMEOUT = 60 # Sekunden je git fetch, damit ein hängender Server nicht blockiert
|
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):
|
if wurzel_ist_repo and gewuenscht(ROOT.name):
|
||||||
befunde.append(Befund(name=ROOT.name, kanal=manifest.get("workspace", {}).get("branch", ""),
|
befunde.append(Befund(name=ROOT.name, kanal=manifest.get("workspace", {}).get("branch", ""),
|
||||||
pfad=ROOT, ist_wurzel=True))
|
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"])]
|
for r in repos if gewuenscht(r["name"])]
|
||||||
|
|
||||||
modus = ("ohne Netz – kein fetch, kein Pull" if args.ohne_netz
|
modus = ("ohne Netz – kein fetch, kein Pull" if args.ohne_netz
|
||||||
else "nur prüfen – fetch, kein Pull" if args.nur_pruefen
|
else "nur prüfen – fetch, kein Pull" if args.nur_pruefen
|
||||||
else "fetch und fast-forward-Pull")
|
else "fetch und fast-forward-Pull")
|
||||||
print(f"Hallo. Workspace: {ROOT}")
|
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)}")
|
print(f"Modus: {modus} | Repositories: {len(befunde)}")
|
||||||
if not wurzel_ist_repo and gewuenscht(ROOT.name):
|
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.")
|
print(f"Hinweis: '{ROOT.name}' selbst ist noch kein Git-Repository – geprüft werden nur die Klone.")
|
||||||
|
|||||||
@@ -24,9 +24,20 @@ import tomllib
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parents[1]
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
LOKALE_ÜBERSCHREIBUNG = ROOT / "workspace.local.toml"
|
||||||
ROLLEN_MIT_PLUGIN = {"plattform", "fachplugin", "geruest"}
|
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:
|
def profil_plugin_ordner(profil: str) -> Path:
|
||||||
if sys.platform.startswith("win"):
|
if sys.platform.startswith("win"):
|
||||||
basis = Path(os.environ.get("APPDATA", Path.home() / "AppData" / "Roaming"))
|
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)")
|
print(" (existiert noch nicht – QGIS mit diesem Profil einmal starten oder --pfad prüfen)")
|
||||||
|
|
||||||
rc = 0
|
rc = 0
|
||||||
|
rroot = repos_root()
|
||||||
for paket in gewuenscht:
|
for paket in gewuenscht:
|
||||||
quelle = ROOT / repos[paket]["name"]
|
quelle = rroot / repos[paket]["name"]
|
||||||
ziel = plugin_ordner / paket
|
ziel = plugin_ordner / paket
|
||||||
if not (quelle / "__init__.py").is_file():
|
if not (quelle / "__init__.py").is_file():
|
||||||
print(f"[{paket}] übersprungen: {quelle.name} enthält kein Plugin (__init__.py fehlt)")
|
print(f"[{paket}] übersprungen: {quelle.name} enthält kein Plugin (__init__.py fehlt)")
|
||||||
|
|||||||
@@ -24,6 +24,17 @@ import tomllib
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parents[1]
|
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]:
|
def git(*args: str, cwd: Path) -> tuple[int, str]:
|
||||||
@@ -78,13 +89,17 @@ def main() -> int:
|
|||||||
manifest = tomllib.load(f)
|
manifest = tomllib.load(f)
|
||||||
ws = manifest["workspace"]
|
ws = manifest["workspace"]
|
||||||
basis_url = f"{ws['gitea']}/{ws['org']}"
|
basis_url = f"{ws['gitea']}/{ws['org']}"
|
||||||
|
rroot = repos_root()
|
||||||
print(f"Workspace: {ROOT}\nGitea: {basis_url}\n")
|
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"]:
|
for repo in manifest["repos"]:
|
||||||
name, branch = repo["name"], repo["branch"]
|
name, branch = repo["name"], repo["branch"]
|
||||||
pfad = ROOT / name
|
pfad = rroot / name
|
||||||
if not (pfad / ".git").is_dir():
|
if not (pfad / ".git").is_dir():
|
||||||
print(f"[{name}] klone Branch {branch} ...")
|
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}"))
|
print(" " + ("ok" if rc == 0 else f"FEHLER: {out}"))
|
||||||
continue
|
continue
|
||||||
git("fetch", "--quiet", "--prune", cwd=pfad)
|
git("fetch", "--quiet", "--prune", cwd=pfad)
|
||||||
|
|||||||
Reference in New Issue
Block a user