#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn generate_pre_commit_hook_with_gates_fast() -> String {
r#"#!/bin/bash
# Pre-commit hook with quality gate executor (fast mode)
# Generated by PMAT ScaffoldEngine - TICKET-PMAT-5021
#
# Fast mode: Runs clippy + tests only (<30s)
# To bypass: git commit --no-verify
# For full gates: Run 'pmat quality-gates' manually
set -e
echo "Running pre-commit quality gates (fast mode)..."
# Check if any source files are staged (skip for docs-only commits)
STAGED_SRC=$(git diff --cached --name-only --diff-filter=ACMR -- '*.rs' '*.py' '*.ts' '*.tsx' '*.js' '*.go' '*.c' '*.cpp' '*.lua' 2>/dev/null || true)
if [ -z "$STAGED_SRC" ]; then
echo "⏭️ No source files staged (docs-only commit) — skipping quality gates"
exit 0
fi
# Clippy (strict mode)
echo "→ Running clippy..."
cargo clippy --all-targets --all-features -- -D warnings
# Tests
echo "→ Running tests..."
cargo test --all-features
echo "✓ All quality gates passed!"
echo "ℹ️ For full coverage/complexity checks, run: pmat quality-gates"
exit 0
"#
.to_string()
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn generate_gate_config_toml() -> String {
r#"# PMAT Quality Gate Configuration
# Generated by PMAT ScaffoldEngine
[gates]
run_clippy = true
clippy_strict = true
run_tests = true
test_timeout = 300
check_coverage = true
min_coverage = 80.0
check_complexity = true
max_complexity = 10
"#
.to_string()
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "path_exists")]
pub fn install_gate_config(project_dir: &Path) -> Result<()> {
use std::fs;
let config_path = project_dir.join(".pmat-gates.toml");
let toml = generate_gate_config_toml();
fs::write(&config_path, toml).map_err(ScaffoldError::IoError)?;
Ok(())
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "path_exists")]
pub fn install_all_hooks_with_gates(project_dir: &Path) -> Result<()> {
let pre_commit = generate_pre_commit_hook_with_gates_fast();
install_pre_commit_hook(project_dir, &pre_commit)?;
install_post_commit_hook(project_dir)?;
install_gate_config(project_dir)?;
Ok(())
}