Use verified SSH profiles from the primary checkout in linked worktrees
This commit is contained in:
+14
-2
@@ -16,8 +16,20 @@ from vm_access_check import load_config
|
|||||||
from vm_mvp_acceptance import protected_json
|
from vm_mvp_acceptance import protected_json
|
||||||
|
|
||||||
|
|
||||||
|
def credentials_directory():
|
||||||
|
local = ROOT / "credentials"
|
||||||
|
if local.exists() or local.is_symlink():
|
||||||
|
return local
|
||||||
|
# Linked worktrees share the original checkout's already verified profiles.
|
||||||
|
common = subprocess.check_output(
|
||||||
|
["git", "-C", str(ROOT), "rev-parse", "--path-format=absolute", "--git-common-dir"],
|
||||||
|
text=True,
|
||||||
|
).strip()
|
||||||
|
return Path(common).parent / "credentials"
|
||||||
|
|
||||||
|
|
||||||
def ssh_prefix(target):
|
def ssh_prefix(target):
|
||||||
credentials = ROOT / "credentials"
|
credentials = credentials_directory()
|
||||||
config = load_config(credentials / ("linux-vm.conf" if target == "linux" else "server.conf"))
|
config = load_config(credentials / ("linux-vm.conf" if target == "linux" else "server.conf"))
|
||||||
host = config["username"] + "@" + config["address"]
|
host = config["username"] + "@" + config["address"]
|
||||||
key = str(Path(config["ssh_key_path"]).expanduser())
|
key = str(Path(config["ssh_key_path"]).expanduser())
|
||||||
@@ -150,7 +162,7 @@ def main():
|
|||||||
if (not path.is_file() or not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9_.-]{0,126}", name)
|
if (not path.is_file() or not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9_.-]{0,126}", name)
|
||||||
or name.endswith(".") or PureWindowsPath(name).is_reserved()):
|
or name.endswith(".") or PureWindowsPath(name).is_reserved()):
|
||||||
parser.error("Reguläre Datei mit portablem Artefaktnamen erwartet")
|
parser.error("Reguläre Datei mit portablem Artefaktnamen erwartet")
|
||||||
if path.resolve().is_relative_to(ROOT / "credentials"):
|
if path.resolve().is_relative_to(credentials_directory()):
|
||||||
parser.error("Zugangsprofile sind keine Entwicklungsartefakte")
|
parser.error("Zugangsprofile sind keine Entwicklungsartefakte")
|
||||||
prefix = None if args.plan else ssh_prefix(args.target)
|
prefix = None if args.plan else ssh_prefix(args.target)
|
||||||
for path in args.files:
|
for path in args.files:
|
||||||
|
|||||||
Reference in New Issue
Block a user