| 1 | import { execFileSync } from "node:child_process"; |
| 2 | |
| 3 | const localFiles = new Set([ |
| 4 | "AGENTS.md", "CONTRIBUTING.md", "RELEASING.md", "CHANGELOG.md", |
| 5 | "release.sh", "tests/release.sh", "flake.nix", "flake.lock", "packaging/nfpm.yaml", |
| 6 | "docs/BACKLOG.md", "docs/agent-vm-upstream.md", "docs/ci-cd.md", |
| 7 | "docs/public-releases.md", "docs/releasing.md", "patches/README.md", |
| 8 | "third_party/SOURCES", "scripts/third-party-sync", |
| 9 | "scripts/guest-os/macos-setup-view.md", "tools/tailnet/README.md", |
| 10 | "www/README.md", "internal/exitpolicy/data/README.md", |
| 11 | "ui/vendor/novnc/README.cage.md", "ui/vendor/novnc/vendor/pako/README.md", |
| 12 | ]); |
| 13 | const localDirectories = [ |
| 14 | "docs/design/", "docs/research/", "docs/plans/", "docs/test-reports/", |
| 15 | "promo/", "ui/prototypes/", ".oil-ui/", |
| 16 | ]; |
| 17 | const tracked = execFileSync("git", ["ls-files", "-z"], { encoding: "utf8" }) |
| 18 | .split("\0").filter(Boolean); |
| 19 | const rejected = tracked.filter(file => |
| 20 | localFiles.has(file) || localDirectories.some(prefix => file.startsWith(prefix)) || |
| 21 | file.startsWith("third_party/") && ( |
| 22 | /\.(?:md|rst|adoc)$/.test(file) || file.includes("/.github/") || |
| 23 | /\/\.(?:gitignore|gitattributes)$/.test(file) |
| 24 | ), |
| 25 | ); |
| 26 | if (rejected.length) { |
| 27 | throw new Error(`Local development material must be ignored, not tracked:\n${rejected.join("\n")}`); |
| 28 | } |
| 29 | if (process.argv.includes("--untracked")) { |
| 30 | const pending = execFileSync("git", ["ls-files", "--others", "--exclude-standard"], { encoding: "utf8" }).trim(); |
| 31 | if (pending) throw new Error(`Classify new files before completing the task:\n${pending}`); |
| 32 | } |
| 33 | console.log(`Verified repository scope for ${tracked.length} tracked files.`); |