-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Automatic git add #64
Comments
Thank you @AquiTCD for question. Have you tried this one?
Just |
Thank you for the answer.
just information, lint-staged struggled this kind of issue before. IMO |
Thank. The concept of a lefthook is different, and we don’t want to be lint-staged on golang. |
For me this is the one feature preventing me from migrating from
Where |
Wanted to chime in with this too, I was really surprised when the job formatted the files but didn't add them to the commit, which was something I expected from a tool like this. Right now this makes it fairly useless when you only want to run something that formats/fixes small errors. I hope you'll consider something like this as it'll make this tool perfect. Thanks for |
Oke, let's give it a try. It would be great if someone will take it. Here's how the task can be achived:
|
I can try to suggest a quick solution, for your issue:
|
AFAIK stashing is used by many git-hooks tools, see for instance For a step-by-step description see the Other useful documentaiton: Stashing involves the risk of manual intervention in case the hook fails badly, see for instance the following two Maybe |
To make it clear, I wrote the information above just trying to help on this. As for myself, I run hooks only to check staged files, as I prefer to fix them manually in case the checks do not pass. So personally I would not even be against the decision to disallow automatic fixing, if it could be dangerous. |
Is there any updates so far? |
Maybe there should be info about this behaviour in this guide https://github.com/evilmartians/lefthook/wiki/Migration-from-husky-with-lint-staged ? Because I think |
I just did the reverse because of this and one other thing I found missing on lefthook.
|
Let's start with stating:
Like many others I switched from Husky + Lint-staged, in my case the reasons were:
Currently my only viable options are:
I think what the majority of people using Lefthook to do
|
Hey @pvds! With 1.3.0 version I've added handling for partially staged files. Now for pre-commit hook unstaged changes are being hidden, and commands run on staged changes only. Then after the hook processing the unstaged changes are applied again. This is not super stable although I haven't noticed any issues related to that. My next step is to decide:
I'm still thinking but I guess that I'm going to implement this feature in 1-2 months (maybe earlier, if there is a request for it). I'll be glad to know what you think about these options. To sum up, my questions:
Namings:
I think the last is the most intriguing question :) |
@mrexox let's start with the most intriguing question! From your suggestions I think My mind started wondering towards including the word
Then again this would make sense in case it's a property of the The changes are made by the run command so For now my answers to your questions would be:
NB. Setting the default value to true would require the feature to be super stable. Would love to hear your considerations. |
I don't recommend changing the default otherwise you may get into the same situation as svg/svgo#1128 and lock this conversation because it may become heated. |
Thank you for participating in this discussion. I guess maybe An example: pre-commit:
commands:
lint:
run: npm run lint --fix
stage_fixed: true I'd like to leave a room for a default behavior but @trajano you are right, it makes sense to leave defaults untouched and then reach out to lefthook users about whether they want to change the default behavior. Also a major version bumping will make sense in this case. |
I agree that we should be careful when changing defaults and take into account the potential impact on the community. However, I also believe it's important to hear different perspectives and ensure that everyone's opinions are valued. While the situation you've referenced is worth considering, it's important to remember that each situation is unique and should be evaluated on its own merits. @mrexox @trajano I agree that we should not make this default behaviour without providing a configuration option to change it. Without more community feedback I agree the default value of this option should not be Considering the name @mrexox I think your I dismissed using 'fixed' while brainstorming because I was thinking that changes made during the pre-commit hook might not always be due to an option called |
Just released 1.3.5 version with this feature included. Please, test it and feel free to open a new issue if you face any problem 🙏 New option docs: |
lefthook is great library, thanks!
I would like to use like
(like
--auto-correct
by RuboCop,--fix
by ESLint)first, I tried like
but it does not work like I expected.
should be alright if the staged range is whole file,
but in the case of staged as hunk(like
git add -p ...
), re-add whole file.Does any one know a solution?
I used use lint-staged and husky like that.
in this case include the result of changing by auto-correct to a commit.
I fixed typo
force-exclution
= >force-exclusion
The text was updated successfully, but these errors were encountered: