From adb486bbb9333704dfce85b3712c5999d1fac3c0 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sun, 12 Nov 2023 20:42:54 +0100 Subject: [PATCH] Add pre-commit hooks This currently checks commit messages and editorconfig. --- .gitlint | 18 ++++++++++++++++++ .pre-commit-config.yaml | 29 +++++++++++++++++++++++++++++ AUTHORS.txt | 7 +++++++ shell.nix | 7 +++++++ 4 files changed, 61 insertions(+) create mode 100644 .gitlint create mode 100644 .pre-commit-config.yaml create mode 100644 AUTHORS.txt diff --git a/.gitlint b/.gitlint new file mode 100644 index 0000000..203a36e --- /dev/null +++ b/.gitlint @@ -0,0 +1,18 @@ +[general] +regex-style-search=true +contrib=contrib-allowed-authors +ignore=body-is-missing + +# While they should be ≤72, 80 is the limit +[title-max-length] +line-length=80 + +# Every message must start with an upper case letter +[title-match-regex] +regex=^[A-Z] + +[ignore-by-title] +regex=^(amend|fixup|squash).* +ignore=title-max-length + +[contrib-allowed-authors] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..eebb675 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,29 @@ +default_install_hook_types: + - commit-msg + - post-commit + - pre-commit + +repos: + - repo: https://github.com/jorisroovers/gitlint + rev: v0.19.1 + hooks: + - id: gitlint + name: Lint git commit message + + - repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: 2.7.3 + hooks: + - id: editorconfig-checker + alias: ec + + - repo: local + hooks: + - id: gitlint-author + name: Check commit author + description: This hook checks the commit author after the commit (without rejecting) + entry: gitlint + language: system + pass_filenames: false + always_run: true + stages: + - post-commit diff --git a/AUTHORS.txt b/AUTHORS.txt new file mode 100644 index 0000000..9910cc5 --- /dev/null +++ b/AUTHORS.txt @@ -0,0 +1,7 @@ +Denis Natusch +Eren Asker +Erik Hohlfeld +Mathis Kral +Paul Heimer +Simon Bruder +Theo Reichert diff --git a/shell.nix b/shell.nix index 098e143..06666a0 100644 --- a/shell.nix +++ b/shell.nix @@ -3,8 +3,15 @@ with pkgs; mkShell { buildInputs = [ asciidoctor + editorconfig-checker + gitlint jdk17 plantuml + pre-commit watchexec # enables automatic compiling on change ]; + + shellHook = '' + pre-commit install + ''; }