Giter Site home page Giter Site logo

Comments (2)

aaronjensen avatar aaronjensen commented on August 18, 2024 3

for reference: https://medium.com/hackernoon/announcing-lint-staged-with-support-for-partially-staged-files-abc24a40d3ff

from lefthook.

ahimta avatar ahimta commented on August 18, 2024 2

Not really sure why this issue is closed as I still have the same problem:

  1. "the commit should have succeeded as the trailing whitespace was only in the unstaged contents"
  2. "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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.