question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trailing whitespace fixer does not work?

See original GitHub issue

Testing it on a simple file with a trailing space:

#' @export 

even when the file is staged,

pre-commit run --all-files -v

returns

Trim Trailing Whitespace.......................................................................................Passed

, but has no visible effect on the file.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Jun 27, 2016

What is the extension of the file? Currently (by default) it matches this list here:

https://github.com/pre-commit/pre-commit-hooks/blob/144c3857cdbba0b758f80aeee9f2adf42ea303ee/hooks.yaml#L143

$ hexdump -C test.sh
00000000  23 27 20 40 65 78 70 6f  72 74 20 0a              |#' @export .|
0000000c
$ pre-commit run --all-files
Trim Trailing Whitespace.................................................Failed
hookid: trailing-whitespace

Files were modified by this hook. Additional output:

Fixing test.sh

Fix End of Files.........................................................Passed
autopep8 wrapper.........................................................Passed
Check docstring is first.................................................Passed
Check JSON...............................................................Passed
Check for added large files..............................................Passed
Check Yaml...............................................................Passed
Debug Statements (Python)................................................Passed
Tests should end in _test.py.............................................Passed
Fix requirements.txt.....................................................Passed
Flake8...................................................................Passed
Validate Pre-Commit Config...............................................Passed
Validate Pre-Commit Manifest.............................................Passed
Reorder python imports...................................................Passed`
$ git diff
diff --git a/test.sh b/test.sh
index 9029ebb..05085ee 100644
--- a/test.sh
+++ b/test.sh
@@ -1 +1 @@
-#' @export 
+#' @export
0reactions
asottilecommented, Jun 27, 2016

via #126

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why isn't my git pre-commit hook trimming white space from ...
So the problem is that it is not trimming the white space at the end of lines. When I open my file after...
Read more >
Trailing Whitespace Fixer - Visual Studio Marketplace
Extension for Visual Studio Code - Automatically removes trailing whitespace when you hit Enter. Also highlights trailing whitespace.
Read more >
trailing-whitespace trims trailing whitespace — Tuto git
Markdown linebreak trailing spaces preserved for .md and`.markdown`;. Use: args: ['–markdown-linebreak-ext=txt,text'] ...
Read more >
Improving your life with pre-commit
As you can see, what's being caught here are largely whitespace issues: I've left trailing whitespace on some lines, and in some cases...
Read more >
Life is Too Short to Review Spaces - GitGuardian Blog
From the git book, git hooks are a way to fire off custom scripts when ... id: check-yaml - id: end-of-file-fixer - id:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found