fix: use git rev-parse for repo root in restart command
The repo_root calculation assumed stack paths are always 4 levels deep (stack_orchestrator/data/stacks/name). External stacks with different nesting (e.g. stack-orchestrator/stacks/name = 3 levels) got the wrong root, causing --spec-file resolution to fail. Use git rev-parse --show-toplevel instead. Fixes: so-k1k Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>afd-dumpster-local-testing
parent
967936e524
commit
2484abfcce
|
|
@ -338,9 +338,22 @@ def restart(ctx, stack_path, spec_file, config_file, force, expected_ip, image):
|
||||||
|
|
||||||
# Determine spec file location
|
# Determine spec file location
|
||||||
# Priority: --spec-file argument > repo's deployment/spec.yml > deployment dir
|
# Priority: --spec-file argument > repo's deployment/spec.yml > deployment dir
|
||||||
# Stack path is like: repo/stack_orchestrator/data/stacks/stack-name
|
# Find repo root via git rather than assuming a fixed directory depth.
|
||||||
# So repo root is 4 parents up
|
git_root_result = subprocess.run(
|
||||||
repo_root = stack_source.parent.parent.parent.parent
|
["git", "rev-parse", "--show-toplevel"],
|
||||||
|
cwd=stack_source,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
if git_root_result.returncode == 0:
|
||||||
|
repo_root = Path(git_root_result.stdout.strip())
|
||||||
|
else:
|
||||||
|
# Fallback: walk up from stack_source looking for .git
|
||||||
|
repo_root = stack_source
|
||||||
|
while repo_root != repo_root.parent:
|
||||||
|
if (repo_root / ".git").exists():
|
||||||
|
break
|
||||||
|
repo_root = repo_root.parent
|
||||||
if spec_file:
|
if spec_file:
|
||||||
# Spec file relative to repo root
|
# Spec file relative to repo root
|
||||||
spec_file_path = repo_root / spec_file
|
spec_file_path = repo_root / spec_file
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue