Open KhizerRehan opened 2 years ago
Just to clarify, it happens even if you're running the mapping under w - commit changes without pre-commit hook
?
Not OP, but I have probably the same setup.
w
and commitgit commit
is missing -n|--no-verify
?)This is what appears in the log(@
)
Commit
git commit -m "test"
Git output:
husky: Running pre-commit hook
[STARTED] Preparing lint-staged...
[SUCCESS] Preparing lint-staged...
[STARTED] Running tasks for staged files...
...
Desktop:
$ lazygit --version
commit=v0.34, build date=2022-04-27T13:28:28Z, build source=binaryRelease, version=0.34, os=linux, arch=amd64
Edit:
Originally I had put the commit message in the log line git commit -m "test"
as git commit -m "WIP"
. Sorry for the confusion.
@la-magra do you have a git.skipHookPrefix
setup in your config.yml
? Could you paste the entirety of your config, please?
Currently the pre-commit hook
is skipped only if the commit message starts with git.skipHookPrefix
, which is WIP
by default. That clarifies why it didn't work for @KhizerRehan . Now that it's discovered why, we'll look into changing the logic that triggers skipping the pre-commit hook
.
@mark2185 My config file in ~/.config/lazygit/config.yml
is completely empty.
I did a quick test putting the default config into it:
$ lazygit -c > ~/.config/lazygit/config.yml
And now if I prefix my commits with "WIP" now the skipHooks command works as intended. Edit: Disregard that, the skipHooks command always worked as intended (putting the WIP prefix in the commit skips the hooks), I didn't test this enough, sorry.
Replacing skipHookPrefix: WIP
by skipHookPrefix: ""
unfortunately does not allow the command to skip hooks since it displays the message You have not configured a commit message prefix for skipping hooks. Set "git.skipHookPrefix = 'WIP'" in your config
.
Great! Now we know what's the cause and we can treat it!
In the meantime, please prefix your commit messages with WIP
for when you want to skip the pre-commit hooks.
As a minor addendum until this issue is solved.
The following custom command does exactly what's required:
customCommands:
- key: "W"
command: git commit --no-verify
context: "global"
subprocess: true
lazygit is just that beautiful.
As a minor addendum until this issue is solved.
The following custom command does exactly what's required:
customCommands: - key: "W" command: git commit --no-verify context: "global" subprocess: true
lazygit is just that beautiful.
Thank you, added commit message prompt also.
customCommands:
- key: "W"
prompts:
- type: "input"
title: "Commit"
initialValue: ""
command: git commit -m "{{index .PromptResponses 0}}" --no-verify
context: "global"
subprocess: true
How do people handle commits when amending a previously skipped commit (which was skipped with the skipHookPrefix
)?
Sort of related to this, but when lazygit runs "commit" indirectly, for example when running a "move patch into new commit", even when the current commit has a "WIP" prefix the commit command that runs from that action won't have the "--no-verify" flag, and from my understanding there is no way to currently do that :/
Hi, I have husky pre-push hook enabled and it is working fine in vscode - windows, but when I try to push from lazy-git in my WSL terminal (Using Astronvim), it is skipping the pre-push hooks and directly pushing. So I basically have the opposite problem to what is described here. Not sure if this is the correct place to ask this.
How do people handle commits when amending a previously skipped commit (which was skipped with the
skipHookPrefix
)?
Also wondering about this. My workflow with WIP commits involves a lot of iteration and lazygit makes that super easy except for this part.
@digitalmaster if you're able to build from source, could you please try out the branch fix-skip-hook
? It's just a dirty commit, but it would confirm that we're headed in the right direction if it works for you.
@mark2185 Works like a charm. Will use for rest of the day and report back if I see any issues but so far so good. Thank you 🙌
Great! I'll open up a PR soon-ish.
Any updates on this?
Any updates on this?
There's a draft PR here that I still haven't gotten around to finishing.
Feel free to take over, though! (or anyone else)
If not, I'll get back around to it, eventually.
Warming up this issue again... 🙉
I see that this
customCommands: - key: "W" prompts: - type: "input" title: "Commit" initialValue: "" command: git commit -m "{{index .PromptResponses 0}}" --no-verify context: "global" subprocess: true
is in principle a solution but I personally do not really understand why lazygit is so opinionated on the pre-commit issue. If there is a separate command with w
, why also check of a prefix?
I'm often working in a codebase where it is pretty much impossible to always solve all pre-commit hooks (something like mypy in a python project). So doing "regular" commits with the -n
flag is quite common. I do not want any WIP or whatever prefix in there. This probably defeats the purpose of pre-commit hooks in some sense but I cannot imagine I'm the only one with that problem.
I think it would be nice to just have an option to disable the prefix check (e.g. setting the prefix to an emptry string).
Topic The project i am working has some Husky hooks are installed like
How i can commit without running such hooks on every commit.
Menu:
Even after running an option does run pre-commit hooks defined in repo:
https://user-images.githubusercontent.com/17727069/172158720-c12bc25a-1a33-4c94-8fb2-ef904190b43a.mp4
Your thoughts What you have to say about the topic