From 855410fcf5e28d37fa3fabec123e891b00396555 Mon Sep 17 00:00:00 2001 From: garrytan Date: Sat, 31 Oct 2026 07:46:25 +0000 Subject: [PATCH] fix: pre-landing review fixes (pass 2) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- bin/gstack-checks | 2 +- lib/checks.ts | 4 +++- test/gstack-checks.test.ts | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/gstack-checks b/bin/gstack-checks index 5da4bd9b7..ffe6ff6c4 100755 --- a/bin/gstack-checks +++ b/bin/gstack-checks @@ -54,7 +54,7 @@ async function main(argv: string[]): Promise { if (nothingToRun(l) && (verb === 'run' || verb === 'detect')) { process.stdout.write(NONE); return verb === 'run' ? 3 : 0; } if (verb === 'detect') { for (const c of l.checks) process.stdout.write(`CHECK ${c.name} ${c.command}${c.body ? ` (runs: ${c.body})` : ''} (${c.source})\n`); - if (!l.checks.length) process.stdout.write('CHECKS: none detected besides tests (no gstack:verify: line, Health Stack section or manifest check)\n'); + if (!l.checks.length) process.stdout.write('CHECKS: tests only (no gstack:verify: line, Health Stack section or manifest check)\n'); const selection = Object.values(l.ctx.config.selection ?? {}); process.stdout.write(`TESTS pregate selection against ${l.ctx.baseRef} (policy ${l.ctx.configLabel}; runner ${l.ctx.config.runner ?? 'detected per file'}${selection.length ? `; selection commands: ${selection.join(' | ')}` : ''})\n`); process.stdout.write(`TRUST ${trusted ? 'trusted' : 'untrusted (run gstack-checks trust after the user agrees, or pass --allow-repo-commands)'}\n`); diff --git a/lib/checks.ts b/lib/checks.ts index f789228de..c9d3b831f 100644 --- a/lib/checks.ts +++ b/lib/checks.ts @@ -100,7 +100,9 @@ export function manifestChecks(root: string): Check[] { if (/\bruff\b/.test(pyproject)) checks.push({ name: 'lint', command: 'ruff check .', source: 'pyproject.toml' }); if (/\bmypy\b/.test(pyproject)) checks.push({ name: 'typecheck', command: 'mypy .', source: 'pyproject.toml' }); } - if (fs.existsSync(path.join(root, 'Cargo.toml'))) checks.push({ name: 'build', command: 'cargo check --all-targets', source: 'Cargo.toml' }, { name: 'lint', command: 'cargo clippy --all-targets', source: 'Cargo.toml' }); + const cargo = read(path.join(root, 'Cargo.toml')); + if (cargo !== null) checks.push({ name: 'build', command: 'cargo check --all-targets', source: 'Cargo.toml' }); + if (cargo !== null && (/^\[(workspace\.)?lints\.clippy\]/m.test(cargo) || ['clippy.toml', '.clippy.toml'].some(f => fs.existsSync(path.join(root, f))))) checks.push({ name: 'lint', command: 'cargo clippy --all-targets', source: 'Cargo.toml' }); if (fs.existsSync(path.join(root, 'go.mod'))) checks.push({ name: 'vet', command: 'go vet ./...', source: 'go.mod' }, { name: 'build', command: 'go build ./...', source: 'go.mod' }); const seen = new Set(); return checks.filter(c => (seen.has(c.name) ? false : (seen.add(c.name), true))); diff --git a/test/gstack-checks.test.ts b/test/gstack-checks.test.ts index 2e7b54399..c5d62ee8f 100644 --- a/test/gstack-checks.test.ts +++ b/test/gstack-checks.test.ts @@ -69,6 +69,13 @@ describe('detection', () => { fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify({ scripts: { lint: 'eslint .' }, devDependencies: { typescript: '5' } })); fs.writeFileSync(path.join(dir, 'go.mod'), 'module x\n'); expect(manifestChecks(dir).map(c => c.command)).toEqual(['bunx tsc --noEmit', 'bun run lint', 'go vet ./...', 'go build ./...']); + // Clippy is a rustup component Cargo.toml does not declare: it runs only when the repo opts in. + const rs = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-checks-rs-')); + dirs.push(rs); + fs.writeFileSync(path.join(rs, 'Cargo.toml'), '[package]\nname = "x"\n'); + expect(manifestChecks(rs).map(c => c.command)).toEqual(['cargo check --all-targets']); + fs.writeFileSync(path.join(rs, 'Cargo.toml'), '[package]\nname = "x"\n[lints.clippy]\npedantic = "warn"\n'); + expect(manifestChecks(rs).map(c => c.command)).toEqual(['cargo check --all-targets', 'cargo clippy --all-targets']); const py = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-checks-py-')); dirs.push(py); expect(manifestChecks(py)).toEqual([]);