Skip to content

Commit d681291

Browse files
committed
fix(audit): include untracked files in cpp_auto_audit
Switches `git ls-files` to `git ls-files --cached --others --exclude-standard` so brand-new untracked .cpp/.hpp files are audited locally before the first commit. Without this, a newly added test file passes local `make lint` (because git ls-files returns nothing for untracked files) but fails CI once the file becomes tracked — caught in kalshi-trader@6a9f656, fix shipped at c13153f. Same fix here for parity across the fleet. No-op for already-passing repos; deduped via a `seen` set in case git emits a path under both --cached and --others.
1 parent 71f41f1 commit d681291

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

tools/cpp_auto_audit.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,27 @@ class Violation:
7777

7878

7979
def tracked_cpp_files(repo_root: Path) -> list[Path]:
80+
# ``git ls-files`` returns tracked files only — a brand-new
81+
# untracked test file is invisible to local audit but still
82+
# caught by CI once it's committed, which makes the divergence
83+
# surface as a CI fail after the developer thought they ran
84+
# lint clean. Also include ``--others --exclude-standard`` so
85+
# untracked-but-not-ignored files (typical for fresh test files)
86+
# get audited too.
8087
proc = subprocess.run(
81-
["git", "ls-files"],
88+
["git", "ls-files", "--cached", "--others", "--exclude-standard"],
8289
cwd=repo_root,
8390
check=True,
8491
capture_output=True,
8592
text=True,
8693
)
94+
seen: set[Path] = set()
8795
files: list[Path] = []
8896
for raw in proc.stdout.splitlines():
8997
path = repo_root / raw
98+
if path in seen:
99+
continue
100+
seen.add(path)
90101
if path.suffix not in CPP_SUFFIXES:
91102
continue
92103
if any(part.startswith("build") for part in path.parts):

0 commit comments

Comments
 (0)