34 lines
1.1 KiB
Bash
Executable File
34 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
workspace_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
|
|
greenfield_root="$workspace_root/greenfield"
|
|
|
|
python3 - "$greenfield_root" <<'PY'
|
|
import pathlib
|
|
import re
|
|
import sys
|
|
|
|
greenfield = pathlib.Path(sys.argv[1]).resolve()
|
|
violations = []
|
|
|
|
for csproj in greenfield.rglob("*.csproj"):
|
|
text = csproj.read_text(encoding="utf-8")
|
|
repo_root = csproj.parents[2].resolve()
|
|
for match in re.finditer(r'<ProjectReference\s+Include="([^"]+)"', text):
|
|
include = match.group(1).replace("\\", "/")
|
|
target = (csproj.parent / include).resolve()
|
|
if not str(target).startswith(str(repo_root)):
|
|
violations.append((csproj.relative_to(greenfield), include, target))
|
|
|
|
if violations:
|
|
print(f"FAILED: found {len(violations)} cross-repo ProjectReference entries")
|
|
for src, include, target in sorted(violations):
|
|
if str(target).startswith(str(greenfield)):
|
|
target = target.relative_to(greenfield)
|
|
print(f"- {src} -> {include} -> {target}")
|
|
raise SystemExit(1)
|
|
|
|
print("PASSED: no cross-repo ProjectReference entries found")
|
|
PY
|