Comments (2)
for reference: https://medium.com/hackernoon/announcing-lint-staged-with-support-for-partially-staged-files-abc24a40d3ff
from lefthook.
Not really sure why this issue is closed as I still have the same problem:
- "the commit should have succeeded as the trailing whitespace was only in the unstaged contents"
- "A similar case exists but in the worse direction (commit allowed but the staged contents are incorrect)"
This compromises the integrity of the pre-commit mechanisms as implied by @asottile excellent points above.
What this means, in not so many words, is that the pre-commit script result depends not on the commit (as in pre-commit) but on whatever was there on the filesystem. Not being too fond of the filesystem is why we use version-control in the first place (I think). It could be argued that not having the pre-commit checks could be better as it currently gives false confidence which means bigger landmines. At least without the pre-commit checks I'd know where I stand, whereas, with the pre-commit checks I'd think I know where I stand (a very big difference).
I typically use pre-commit checks as a local CI so that I can guarantee that each and every commit passes them. This has some huge benefits but, unfortunately, they are the kind that you only value if you don't have tolerance for landmines that can waste days and can be prevented with some simple mechanisms. And the most important features of a product is those that users don't know about since they can't advocate for them and maintainers can't know them easily.
For me, Lefthook right now is like ./scripts/<pre-commit-check-script> && commit
. For some people it might be a convenience for the script to run in all cases (e.g: committing from a UI).
These unpopular but crucial issues are one reason that I often write tools myself in a shorter time than finding a reliable tool (which doesn't always exist).
For example, I have written a tool that simply copies the repo and discards all changes that aren't going to be committed and run the pre-commit checks and then remove the copy. I hoped that Lefthook would make it possible to replace my own tool but this doesn't seem to be the case.
I don't really understand if this issue isn't at the core of what Lefthook does then what is. I'm definitely biased as this is my main usecase for hooks and would appreciate your dismissing of my elitist and slightly arrogant style and focus on the point at hand.
As an aside, I see the other major feature requested is to run the pre-commit checks only on changed files and I've worked on projects that benefit greatly from this. I think these two major features should be taken very seriously and not be treated like another couple of open issues.
Here are some of the related issues that I came across along the way:
from lefthook.
Related Issues (20)
- new feature refetch remotes config sync hooks fail HOT 15
- Paths with brackets parsed incorrectly in Windows environment HOT 3
- 1.6.16 not available in apt/rpm repos HOT 1
- Bug: Global extend options will take precedence over local options HOT 7
- postinstall does not get executed with pnpm HOT 1
- can't evaluate field Extension in type string HOT 1
- Installation command creates a folder named --help HOT 5
- npx lefthook throwing `command not found` HOT 3
- git commit command with error in macos `14.4.1` for M3. HOT 5
- Skip hook/command when commit message matches a pattern HOT 2
- Does not work correctly if there are multiple excludes HOT 2
- Version 1.7.6 fails installation on CI HOT 4
- Provide a default branch for {push_files} HOT 1
- Invalid escaping of {staged_files} HOT 15
- Use git rev-parse origin/<branch-name> to get latest pushed ref
- Explain how "run" runs whatever it is its value represents HOT 1
- "unknown revision or path not in the working tree" from 1.6.15 onwards HOT 4
- Can't exclude multiple files. HOT 4
- stage_fixed (or equivalent) for changed files not originally staged HOT 2
- Support OpenBSD HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lefthook.