From 90ddef5a419bae0f2cc33f3156d7d221a501f378 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Thu, 22 Sep 2022 14:53:26 +0000 Subject: [PATCH] pre-commit: Provide pre-commit configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add pre-commit (https://pre-commit.com/) configuration to allow developers to run certain checks on their commits automatically. Currently enabled checks and hooks are: - Generic checks (e.g. merge-conflicts, trailing whitespace, etc.) - git clang-format - Codespell - Shellcheck (https://www.shellcheck.net/) Note: For some hooks Rust is excluded as a lot of false positives are produced at the moment. Signed-off-by: Marc Hartmayer Reviewed-by: Jan Höppner Reviewed-by: Steffen Eiden Signed-off-by: Steffen Eiden Signed-off-by: Jan Höppner --- .codespell.ignore | 2 -- .pre-commit-config.yaml | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.codespell.ignore b/.codespell.ignore index 94c0c59d..289b45a2 100644 --- a/.codespell.ignore +++ b/.codespell.ignore @@ -1,5 +1,3 @@ parm parms crate -ser -deriver diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..20e3ecb9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +--- +exclude: \.(crt|crl)$ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: check-merge-conflict + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + exclude_types: ['rust'] + - repo: local + hooks: + - id: git-clang-format + name: git-clang-format + description: Run git-clang-format + entry: git + args: [clang-format, --staged, --] + pass_filenames: true + language: system + require_serial: true + minimum_pre_commit_version: "2.9.0" + types_or: [c++, c] + - repo: https://github.com/codespell-project/codespell + rev: v2.2.1 + hooks: + - id: codespell + exclude_types: ['rust'] + - repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 3.0.0 + hooks: + - id: shellcheck + args: ["--external-sources"]