Git prepare-commit-msg hook seems not work in PyCharm

0

I am working with the last version of PyCharm. In our repo we have some hooks, like "prepare-commit-msg" to create a commit template or "commit-msg" using by Gerrit to add the change-id used by this team code collaboration tool.

All of them work perfectly in the terminal but it seems that they are not executed by PyCharm.

Is it a bad PyCharm configuration or git hooks doesn't work in the IDE?

Fran Moya

Posted 2019-08-21T09:38:04.893

Reputation: 1

Answers

0

I ran into this too (using PyCharm 2019.1 Professional Edition). I asked the folks at JetBrains, and they pointed me to the relevant ticket:

https://youtrack.jetbrains.com/issue/IDEA-114680

Unfortunately, it's an old old issue with few upvotes (I just added one now). The crux of the issue is noted in the first comment by Kirill:

The problem is that Commit Dialog is shown before git commit is called, and thus before any pre-commit hooks are called.

Note though that the hook is being executed...eventually.

In my case, I found this out accidentally when I had finally given up. I went on, as usual. I prefixed my ticket number to the commit message, committed, pushed the change, and then noticed that the ticket number showed up twice (e.g. "[ABC-123] ABC-123 add feature x").

Mike

Posted 2019-08-21T09:38:04.893

Reputation: 101