Running commit checks before commit
On one instance of IntelliJ, when I commit code to Git the code will be committed and then it runs the “commit checks” (reformat code, Analyze Code, Check TODO, Run Git Hooks). I don't remember doing anything to change this. Previously it would run these checks before committing the code and prompt me if there were any warnings or new TODOs. I do have IntelliJ installed on a second computer and there I have the expected experience.
Is there a setting somewhere that could have gotten set accidentally? I did uninstall and reinstall IntelliJ without resolving this issue.
The topic Modal commit dialog with background code analysis? – IDEs Support (IntelliJ Platform) | JetBrains seems to suggest “post-commit checks” which sounds like what is happening, but doesn't indicate how to configure pre-commit v. post-commit. Also, not entirely clear that this topic doesn't just mean "after hitting the commit button" when it refers to post-commit checks.
In my case, the actions are actually happening after the commit. for example, it will give a message that there are “Warnings” after the commit has already occurred or it will reformat the code for some of the files so that there is another separate commit waiting.
请先登录再写评论。
I believe I may have found the cause for this related to different behavior for Commit v. Commit and Push. Commit seems to commit the changes and then perform commit checks. Commit and Push performs the checks before the commit takes place. I believe on the machine where I was seeing the issues, I had gotten in the habit of just pushing Commit because I had seen the issue previously. This would allow me to drop the commit and commit again with any additional fixes based on the analyze.
I do believe it would be helpful if the Commit worked similar to Commit and Push, performing the commit checks first. I don't want to commit code with potential errors until I review them. This can lead to issues when cherry picking to another branch because functionality gets broken up into multiple commits.
Alternatively, this could be a setting, but I am not sure why you would want to create multiple commits in this situation.
Hi,
This has been a change since 2023.1, please see: https://youtrack.jetbrains.com/issue/IJPL-73206/Allow-turning-off-background-precommit-check
Feel free to vote and comment there.