mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: add linting pre-commit hook
This commit is contained in:
16
rust/lint.py
Executable file
16
rust/lint.py
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/env python3
|
||||
|
||||
import subprocess
|
||||
import pathlib
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
extractor_dir = pathlib.Path(__file__).resolve().parent / "extractor"
|
||||
|
||||
cargo = shutil.which("cargo")
|
||||
assert cargo, "no cargo binary found on `PATH`"
|
||||
|
||||
fmt = subprocess.run([cargo, "fmt", "--quiet"], cwd=extractor_dir)
|
||||
clippy = subprocess.run([cargo, "clippy", "--fix", "--allow-dirty", "--allow-staged", "--quiet"],
|
||||
cwd=extractor_dir)
|
||||
sys.exit(fmt.returncode or clippy.returncode)
|
||||
Reference in New Issue
Block a user