{"record":{"id":"c0622ed116035f4e","repo":"nikivdev/code","slug":"commit-blocked-by-testing-gate","errorCode":null,"errorMessage":"Commit blocked by testing gate","messagePattern":"Commit blocked by testing gate","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/commit.rs","lineNumber":3677,"sourceCode":"            ));\n            continue;\n        }\n\n        if strict_bun_repo && !cmd.contains(\"bun bd test\") {\n            violations.push(format!(\n                \"task '{}' must use `bun bd test` in Bun repo: {}\",\n                task.name, task.command\n            ));\n        }\n    }\n\n    violations\n}\n\nfn apply_testing_gate_failure(mode: &str, message: &str) -> Result<()> {\n    eprintln!(\"  testing: {}\", message);\n    if mode == \"block\" {\n        bail!(\"Commit blocked by testing gate\");\n    }\n    eprintln!(\"  testing: warning only (mode=warn)\");\n    Ok(())\n}\n\nfn run_pre_commit_test_gate(\n    repo_root: &Path,\n    changed_files: &[String],\n    gate_overrides: CommitGateOverrides,\n) -> Result<()> {\n    if gate_overrides.skip_quality || gate_overrides.skip_tests {\n        if gate_overrides.skip_tests {\n            println!(\"Skipping test gate due to --skip-tests\");\n        }\n        return Ok(());\n    }\n\n    let policy = resolve_commit_testing_policy(repo_root);","sourceCodeStart":3659,"sourceCodeEnd":3695,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/commit.rs#L3659-L3695","documentation":"apply_testing_gate_failure centralizes testing-gate enforcement: it prints the violation message and, when mode == \"block\", bails so the commit is aborted. In \"warn\" mode it only prints a warning and returns Ok. The pre-commit test gate uses this to block commits that fail required tests.","triggerScenarios":"Committing while the pre-commit test gate (run_pre_commit_test_gate) detects violations — failing or missing required tests — with gate mode configured to \"block\".","commonSituations":"Committing with a red test suite; tests not yet written for new code where policy requires them; flaky tests failing in the pre-commit run; test runner unavailable in the environment (missing toolchain/CI deps).","solutions":["Run the project's test suite locally, fix failures, then commit again.","Check the printed `testing: <message>` line to see exactly which test/requirement failed.","Ensure the test toolchain is installed and runnable in your environment.","For known-flaky tests, stabilize or quarantine them rather than disabling the gate."],"exampleFix":"// before: commit attempted with failing test\n$ commit -m \"wip\"\n// testing: test parse_config failed\n// after fixing\n$ cargo test -- parse_config // green\n$ commit -m \"wip\" // passes gate","handlingStrategy":"validation","validationCode":"// Ensure the test suite is green before attempting a gated commit\nlet ok = Command::new(\"cargo\").args([\"test\"]).status()?.success();\nif !ok { return Err(\"tests must pass before committing (testing gate mode=block)\".into()); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = commit_flow() {\n    if e.to_string().contains(\"Commit blocked by testing gate\") {\n        eprintln!(\"run the test suite, fix the failure shown in 'testing: ...', retry\");\n    } else { return Err(e.into()); }\n}","preventionTips":["Run the full test suite before every commit, not just in CI.","Keep required tests present for new code paths to satisfy the gate.","Fix or quarantine flaky tests promptly; never disable the gate to force commits."],"tags":["git","pre-commit","testing","policy-gate"],"backgroundTag":"commit-blocked-by-gate","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}