From 8b0cb60e134bd2b788ca0a86318b739d0a99666e Mon Sep 17 00:00:00 2001 From: Nydragon Date: Fri, 24 May 2024 22:21:36 +0900 Subject: [PATCH] chore: add pre-commit --- .pre-commit-config.yaml | 37 +++++++++++++++++++++++++++++++++++++ committed.toml | 20 ++++++++++++++++++++ flake.nix | 3 +++ 3 files changed, 60 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 committed.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b3b984e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,37 @@ +default_install_hook_types: + - pre-commit + - commit-msg + +repos: + - repo: https://github.com/gitleaks/gitleaks + rev: v8.18.2 + hooks: + - id: gitleaks + + - repo: local + hooks: + - id: committed + name: Lint commit message + entry: committed + language: system + files: .* + args: [--fixup, --wip, --commit-file] + stages: [commit-msg] + + - id: fmt + name: Lint Check + entry: cargo + language: system + files: .* + args: [fmt, --check] + pass_filenames: false + stages: [commit] + + - id: clippy + name: Check clippy suggestions + entry: cargo + language: system + files: .* + args: [clippy] + pass_filenames: false + stages: [commit] diff --git a/committed.toml b/committed.toml new file mode 100644 index 0000000..20fdfaa --- /dev/null +++ b/committed.toml @@ -0,0 +1,20 @@ +subject_length = 100 +subject_capitalized = false +subject_not_punctuated = true +imperative_subject = true +no_fixup = true +no_wip = true +hard_line_length = 0 +line_length = 120 +style = "conventional" +allowed_types = [ + "fix", + "feat", + "chore", + "docs", + "style", + "refactor", + "perf", + "test", +] +merge_commit = true diff --git a/flake.nix b/flake.nix index 4308b44..03580ff 100644 --- a/flake.nix +++ b/flake.nix @@ -46,6 +46,7 @@ buildInputs = [ (rustVersion.override { extensions = [ "rust-src" ]; }) pkgs.git-cliff + pkgs.committed ]; shellHook = let @@ -61,6 +62,8 @@ echo "Use ${rofiDebug} to build and run the debuging version with rofi." echo "Use ${rofiRelease} to build and run the release version with rofi." + + ${pkgs.pre-commit}/bin/pre-commit install -f ''; }; }