From b5aa5c6b2f427451b872c0089783ed8464d0689c Mon Sep 17 00:00:00 2001 From: azriel1rf Date: Sat, 4 May 2024 12:29:18 +0900 Subject: [PATCH] Show diff from formatted code on pre-commit --- .pre-commit-config.yaml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 038d928..bbbb1d9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,6 @@ repos: - id: forbid-submodules fail_fast: true - id: detect-private-key - fail_fast: true - id: fix-byte-order-marker - id: mixed-line-ending - id: trailing-whitespace @@ -27,21 +26,20 @@ repos: hooks: - id: remove-crlf - id: remove-tabs - verbose: true # Formatting for Python configuration files - repo: https://github.com/asottile/setup-cfg-fmt rev: v2.5.0 hooks: - id: setup-cfg-fmt + verbose: true # Linting and formatting for C++ - repo: https://github.com/pocc/pre-commit-hooks rev: v1.3.5 hooks: - id: clang-format - args: [-i] - verbose: true + args: [-i, --Werror] # - id: clang-tidy # - id: oclint # - id: cppcheck @@ -60,10 +58,9 @@ repos: # Linting for Python - id: ruff-check name: Python - Linting with Ruff - entry: bash -c 'pip install ruff && cd python && ruff check' + entry: bash -c 'pip install ruff && cd python && ruff check --diff' language: system types_or: [python] - verbose: true pass_filenames: false # Formatting for Python @@ -72,7 +69,6 @@ repos: entry: bash -c 'pip install ruff && cd python && ruff format' language: system types_or: [python] - verbose: true pass_filenames: false # Type checking for Python @@ -81,7 +77,6 @@ repos: entry: bash -c 'pip install mypy && cd python && mypy .' language: system types_or: [python] - verbose: true pass_filenames: false stages: - pre-commit @@ -94,10 +89,17 @@ repos: name: run unit tests entry: python -m unittest discover language: system - verbose: true pass_filenames: false stages: - pre-commit - pre-merge-commit - pre-rebase - manual + + # Display the differences between the original and formatted code + - id: git-diff + name: git diff + entry: git diff --exit-code + language: system + pass_filenames: false + always_run: true