Skip to content

Commit

Permalink
build: add git pre-commit hook
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Castro <[email protected]>
  • Loading branch information
tiagolobocastro committed Jan 25, 2024
1 parent cb9bb0c commit c443473
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/.vagrant
.idea
.pregenerated
/Cargo.lock
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
repos:
- repo: https://github.com/nix-community/nixpkgs-fmt
rev: v1.2.0
hooks:
- id: nixpkgs-fmt
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
exclude_types: [diff]
- repo: local
hooks:
- id: rust-style
name: Rust style
description: Check Rust code style on files included in the commit.
entry: ./scripts/rust-style.sh
pass_filenames: false
types: [file, rust]
language: system
- id: rust-lint
name: Rust lint
description: Run Rust linter on files included in the commit.
entry: ./scripts/rust-linter.sh
pass_filenames: false
types: [file, rust]
language: system
- id: commit-lint
name: Commit Lint
description: Runs commitlint against the commit message.
language: system
entry: bash -c 'nix-shell --pure --run "cat $1 | grep -v '^#' | commitlint"'
args: [$1]
stages: [commit-msg]
15 changes: 15 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# changed from 100 to 80
max_width = 80
# default is false
wrap_comments = true
comment_width = 80
# was true
struct_lit_single_line = false
#changed from Mixed
imports_layout = "HorizontalVertical"
# changed from Preserve (merge_imports = false)
imports_granularity="Crate"
#default false
spaces_around_ranges = true
# was 2015
edition = "2018"
3 changes: 3 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ mkShell {
udev
utillinux
yasm
commitlint
] ++ (if (nospdk) then [ spdk.buildInputs ] else [ spdk ]);

NODE_PATH = "${nodePackages."@commitlint/config-conventional"}/lib/node_modules";

LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
SPDK_PATH = if nospdk then null else "${spdk}";
FIO_SPDK = if nospdk then null else "${spdk}/fio/spdk_nvme";
Expand Down

0 comments on commit c443473

Please sign in to comment.