The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(hooks): treat .cargo config as a Rust change; isolate the hook tests
obchaincd12dc043cef
diff --git a/.husky/pre-push b/.husky/pre-pushindex 7ce5cdebc9..c47dc895e3 100755--- a/.husky/pre-push+++ b/.husky/pre-push@@ -94,7 +94,7 @@ push_touches_rust() {return 0fiprintf '%s\n' "$PUSHED_PATHS" | grep -Eq \- '(^|/)[^/]+\.rs$|(^|/)Cargo\.(toml|lock)$|(^|/)rust-toolchain\.toml$|^crates/|^vendor/|^UNRESOLVED$'+ '(^|/)[^/]+\.rs$|(^|/)Cargo\.(toml|lock)$|(^|/)rust-toolchain\.toml$|^\.cargo/|^crates/|^vendor/|^UNRESOLVED$'}# Windows Git Bash can miss Node/Pnpm in PATH when hooks run.diff --git a/AGENTS.md b/AGENTS.mdindex 8e55fea49d..defa958ec9 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -554,7 +554,8 @@ serialization.- Use the issue and PR templates.- Fix hook failures caused by your changes.- `.husky/pre-push` runs `rust:clippy` only when the push carries Rust- (`*.rs`, a manifest, `crates/`, `vendor/`, `rust-toolchain.toml`); it runs+ (`*.rs`, a manifest, `.cargo/`, `crates/`, `vendor/`,+ `rust-toolchain.toml`); it runsanyway when the range cannot be resolved, or with`PRE_PUSH_FORCE_CLIPPY=1`. `scripts/__tests__/pre-push-hook.test.mjs`covers the hook.diff --git a/scripts/__tests__/pre-push-hook.test.mjs b/scripts/__tests__/pre-push-hook.test.mjsindex f23aa2d9c1..83a19cbbc6 100644--- a/scripts/__tests__/pre-push-hook.test.mjs+++ b/scripts/__tests__/pre-push-hook.test.mjs@@ -9,6 +9,10 @@ import { fileURLToPath } from 'node:url';const REPO_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '../..');const HOOK = resolve(REPO_ROOT, '.husky/pre-push');const ZERO_OID = '0'.repeat(40);+// Keep every git process off the developer's own config: a global+// `commit.gpgsign` or `core.hooksPath` would fail these commits for reasons+// that have nothing to do with the hook under test.+const GIT_ENV = { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_SYSTEM: '/dev/null' };const workspaces = [];after(() => {@@ -16,7 +20,7 @@ after(() => {});function git(cwd, ...args) {- return execFileSync('git', args, { cwd, encoding: 'utf8' }).trim();+ return execFileSync('git', args, { cwd, encoding: 'utf8', env: GIT_ENV }).trim();}/**@@ -36,7 +40,7 @@ function workspace() {mkdirSync(repo);mkdirSync(bin);- execFileSync('git', ['init', '--quiet', '--bare', origin]);+ execFileSync('git', ['init', '--quiet', '--bare', origin], { env: GIT_ENV });git(repo, 'init', '--quiet', '--initial-branch=main');git(repo, 'config', 'user.email', '[email protected]');git(repo, 'config', 'user.name', 'hook test');@@ -77,7 +81,7 @@ function runHook(ws, refLines, { fail = '', env = {} } = {}) {encoding: 'utf8',input: refLines.map(line => `${line}\n`).join(''),env: {- ...process.env,+ ...GIT_ENV,PATH: `${ws.bin}:${process.env.PATH}`,PNPM_LOG: ws.log,PNPM_FAIL: fail,@@ -139,6 +143,13 @@ test('a push that touches a manifest still runs rust:clippy', () => {assert.equal(ranClippy(runHook(ws, [line])), true);});+test('a push that touches .cargo config still runs rust:clippy', () => {+ // Compiler flags, linker and target settings live there; they change what+ // clippy sees without touching a `.rs` file.+ const { ws, line } = pushOf('.cargo/config.toml', '[build]\n');+ assert.equal(ranClippy(runHook(ws, [line])), true);+});+test('a push that touches a vendored submodule path still runs rust:clippy', () => {const { ws, line } = pushOf('vendor/tinyagents/notes.md', 'x\n');assert.equal(ranClippy(runHook(ws, [line])), true);