Skip to content

Commit f115701

Browse files
authored
Merge pull request #6 from gaelic-ghost/build/fix-repo-maintenance-root-resolution
Fix repo-maintenance root resolution in generated toolkit
2 parents 1aac8c4 + 997978e commit f115701

5 files changed

Lines changed: 46 additions & 8 deletions

File tree

skills/bootstrap-swift-package/assets/repo-maintenance/lib/common.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/env sh
22
set -eu
33

4-
COMMON_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
5-
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_DIR/.." && pwd)
4+
COMMON_CONTEXT_DIR=${SELF_DIR:-}
5+
[ -n "$COMMON_CONTEXT_DIR" ] || COMMON_CONTEXT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
6+
if [ -f "$COMMON_CONTEXT_DIR/lib/common.sh" ]; then
7+
REPO_MAINTENANCE_ROOT="$COMMON_CONTEXT_DIR"
8+
else
9+
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_CONTEXT_DIR/.." && pwd)
10+
fi
611
REPO_ROOT=$(CDPATH= cd -- "$REPO_MAINTENANCE_ROOT/../.." && pwd)
712
REPO_MAINTENANCE_PROFILE="generic"
813
REPO_MAINTENANCE_PROFILE_DESCRIPTION="Generic repo-maintenance baseline with no Swift or Xcode specialization."

skills/bootstrap-xcode-app-project/assets/repo-maintenance/lib/common.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/env sh
22
set -eu
33

4-
COMMON_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
5-
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_DIR/.." && pwd)
4+
COMMON_CONTEXT_DIR=${SELF_DIR:-}
5+
[ -n "$COMMON_CONTEXT_DIR" ] || COMMON_CONTEXT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
6+
if [ -f "$COMMON_CONTEXT_DIR/lib/common.sh" ]; then
7+
REPO_MAINTENANCE_ROOT="$COMMON_CONTEXT_DIR"
8+
else
9+
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_CONTEXT_DIR/.." && pwd)
10+
fi
611
REPO_ROOT=$(CDPATH= cd -- "$REPO_MAINTENANCE_ROOT/../.." && pwd)
712
REPO_MAINTENANCE_PROFILE="generic"
813
REPO_MAINTENANCE_PROFILE_DESCRIPTION="Generic repo-maintenance baseline with no Swift or Xcode specialization."

skills/sync-swift-package-guidance/assets/repo-maintenance/lib/common.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/env sh
22
set -eu
33

4-
COMMON_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
5-
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_DIR/.." && pwd)
4+
COMMON_CONTEXT_DIR=${SELF_DIR:-}
5+
[ -n "$COMMON_CONTEXT_DIR" ] || COMMON_CONTEXT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
6+
if [ -f "$COMMON_CONTEXT_DIR/lib/common.sh" ]; then
7+
REPO_MAINTENANCE_ROOT="$COMMON_CONTEXT_DIR"
8+
else
9+
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_CONTEXT_DIR/.." && pwd)
10+
fi
611
REPO_ROOT=$(CDPATH= cd -- "$REPO_MAINTENANCE_ROOT/../.." && pwd)
712
REPO_MAINTENANCE_PROFILE="generic"
813
REPO_MAINTENANCE_PROFILE_DESCRIPTION="Generic repo-maintenance baseline with no Swift or Xcode specialization."

skills/sync-xcode-project-guidance/assets/repo-maintenance/lib/common.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/env sh
22
set -eu
33

4-
COMMON_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
5-
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_DIR/.." && pwd)
4+
COMMON_CONTEXT_DIR=${SELF_DIR:-}
5+
[ -n "$COMMON_CONTEXT_DIR" ] || COMMON_CONTEXT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
6+
if [ -f "$COMMON_CONTEXT_DIR/lib/common.sh" ]; then
7+
REPO_MAINTENANCE_ROOT="$COMMON_CONTEXT_DIR"
8+
else
9+
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_CONTEXT_DIR/.." && pwd)
10+
fi
611
REPO_ROOT=$(CDPATH= cd -- "$REPO_MAINTENANCE_ROOT/../.." && pwd)
712
REPO_MAINTENANCE_PROFILE="generic"
813
REPO_MAINTENANCE_PROFILE_DESCRIPTION="Generic repo-maintenance baseline with no Swift or Xcode specialization."

tests/test_swift_package_guidance_sync_workflow.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,24 @@ def test_sync_creates_agents_template(self) -> None:
9494
)
9595
self.assertTrue(Path(tmpdir, ".github/workflows/validate-repo-maintenance.yml").is_file())
9696

97+
def test_generated_repo_maintenance_validation_uses_repo_self_dir(self) -> None:
98+
with tempfile.TemporaryDirectory() as tmpdir:
99+
Path(tmpdir, "Package.swift").write_text("// swift-tools-version: 6.0\n", encoding="utf-8")
100+
code, payload = self.run_script("--repo-root", tmpdir)
101+
self.assertEqual(code, 0)
102+
self.assertEqual(payload["status"], "success")
103+
104+
subprocess.run(["git", "init"], cwd=tmpdir, check=True, capture_output=True, text=True)
105+
proc = subprocess.run(
106+
["sh", "scripts/repo-maintenance/validate-all.sh"],
107+
cwd=tmpdir,
108+
capture_output=True,
109+
text=True,
110+
check=False,
111+
)
112+
self.assertEqual(proc.returncode, 0, proc.stderr or proc.stdout)
113+
self.assertIn("Repo-maintenance validation completed successfully.", proc.stdout)
114+
97115
def test_sync_appends_section_to_existing_agents(self) -> None:
98116
with tempfile.TemporaryDirectory() as tmpdir:
99117
Path(tmpdir, "Package.swift").write_text("// swift-tools-version: 6.0\n", encoding="utf-8")

0 commit comments

Comments
 (0)