From 59112382ae1bbb55a7371c41dc50a9e86b30e3af Mon Sep 17 00:00:00 2001 From: Enrique Vallespi Gil Date: Mon, 30 Mar 2026 13:07:08 +0200 Subject: [PATCH] Adding a custom entry for trailling-whitespace We're adding a wrapper around trailing-whitespace-fixer, which is the default entry https://github.com/pre-commit/pre-commit-hooks/blob/main/.pre-commit-hooks.yaml#L205 So now, instead of directly call it, we are checking if is there any space in the files, if so, then we add it to the list and we call trailing-whitespace-fixer. if not file, then we don't execute anything and we retrieve success. Apart of impacting positive as we're not calling by default the trailing-whitespace-fixer python script, now we can see the files that needs to remove the whitespace. Signed-off-by: Enrique Vallespi Gil --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index db52b1d7ad..f4fb4f44f9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,6 +5,7 @@ repos: hooks: - id: end-of-file-fixer - id: trailing-whitespace + entry: bash -c 'affected_files=(); for f in "$@"; do grep -l "[[:space:]]$" "$f" 2>/dev/null && affected_files+=("$f"); done; if [ ${#affected_files[@]} -gt 0 ]; then trailing-whitespace-fixer "${affected_files[@]}"; exit $?; else exit 0; fi' -- - id: mixed-line-ending - id: check-byte-order-marker - id: check-executables-have-shebangs