From 0fcd617cf4e4c149de710a68fab24e45897519cd Mon Sep 17 00:00:00 2001 From: kajman Date: Wed, 31 Aug 2022 21:53:00 +0200 Subject: [PATCH 1/4] Added cargo test hook --- .pre-commit-hooks.yaml | 7 +++++++ 1 file changed, 7 insertions(+) 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 From 242e568e61622c02f561679165b2b68b91a2eee5 Mon Sep 17 00:00:00 2001 From: kajman Date: Wed, 31 Aug 2022 21:56:12 +0200 Subject: [PATCH 2/4] Removed unused hooks file --- hooks.yaml | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 hooks.yaml 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 From 50349d014a898c6436f8ac1f80728b8c0002c93e Mon Sep 17 00:00:00 2001 From: kajman Date: Wed, 31 Aug 2022 22:02:02 +0200 Subject: [PATCH 3/4] Extended readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 12d3b83..f2a96dc 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,9 @@ rev: master hooks: - id: fmt + - id: clippy - id: cargo-check + - id: cargo-test ``` ## Passing arguments to rustfmt From 280fbc455c6ac7ebba62d9d63fe26d800189c0a4 Mon Sep 17 00:00:00 2001 From: kajmaj87 Date: Wed, 31 Aug 2022 22:21:56 +0200 Subject: [PATCH 4/4] Update README.md --- README.md | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f2a96dc..fb6366e 100644 --- a/README.md +++ b/README.md @@ -2,24 +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: clippy - - id: cargo-check - - id: cargo-test +- 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', '--'] ```