diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 0ffe38d..35ae8af 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -12,6 +12,13 @@ language: system types: [rust] pass_filenames: false +- id: cargo-test + name: cargo test + description: Run tests + entry: cargo test + language: system + types: [rust] + pass_filenames: false - id: clippy name: clippy description: Lint rust sources diff --git a/README.md b/README.md index 12d3b83..fb6366e 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,38 @@ [Rust](https://www.rust-lang.org) tools package for [pre-commit](https://pre-commit.com). -## Using rust tools with pre-commit +## Usage +Install pre-commit: +`pip install pre-commit` + +Create .pre-commit-config.yaml in your main project dir with the following content: ```yaml -- repo: https://github.com/doublify/pre-commit-rust - rev: master - hooks: - - id: fmt - - id: cargo-check +- repo: https://github.com/kajmaj87/pre-commit-rust + rev: v1.0 + hooks: + - id: fmt + - id: clippy + - id: cargo-check + - id: cargo-test +``` +Choose plugins and their order from the above list as needed. + +Then run: + +``` +$ pre-commit install +$ pre-commit run --all-files ``` +After that you it will be checked before each commit. + ## Passing arguments to rustfmt ```yaml -- repo: https://github.com/doublify/pre-commit-rust - rev: master - hooks: - - id: fmt - args: ['--verbose', '--edition', '2018', '--'] +- repo: https://github.com/kajmaj87/pre-commit-rust + rev: v1.0 + hooks: + - id: fmt + args: ['--verbose', '--edition', '2018', '--'] ``` diff --git a/hooks.yaml b/hooks.yaml deleted file mode 100644 index 8c60d0d..0000000 --- a/hooks.yaml +++ /dev/null @@ -1,21 +0,0 @@ -- id: fmt - name: fmt - description: Format files with cargo fmt. - entry: cargo fmt -- - language: system - files: \.rs$ - args: [] -- id: cargo-check - name: cargo check - description: Check the package for errors. - entry: cargo check - language: system - files: \.rs$ - pass_filenames: false -- id: cargo-clippy - name: cargo clippy - description: Run the Clippy linter on the package. - entry: cargo clippy -- -D warnings - language: system - files: \.rs$ - pass_filenames: false