How to listen a git push event in a plugin
Answered
I'm working for a shcool charitable project ,now I need to execute some code after a git push event,
but I find that GitPushProcessCustomizationFactory.java has been deleted. So what to do ? Please.
Please sign in to leave a comment.
Hello,
Yes, there's no such API available anymore.
Could you clarify the use case? There might be another suitable workaround.
Hello,
I am developing a plugin for intellij and i want to get a listener or an event after the user press the push button in github. Is a class to use for this purpose ? I found this class but it doesnt exists anymore https://upsource.jetbrains.com/idea-ce/file/idea-ce-c70960c5b17fe3fa9b15e982377d45f12d09983a/plugins/git4idea/src/git4idea/push/GitPushProcessCustomizationFactory.java?nav=2537:2615:focused&line=60&preview=false . I want something similar
PrePushHandler can perform some checks right before push (ex: validate commit messages).
https://github.com/JetBrains/intellij-community/blob/28c662f9f65b3425cc2953bedbfd3bb54d558870/platform/dvcs-impl/src/com/intellij/dvcs/push/PrePushHandler.java
https://github.com/JetBrains/intellij-community/blob/2bb5f9a8563cc87aea464cdf45a74ad040060fff/plugins/devkit/intellij.devkit.git/src/KotlinPluginPrePushHandler.kt
Thanks very much..So after the user press the push button from the dialog then handle method execute and then the push taking place is that right? Do you have a snipet of code to understand how i can implement this ?
>Do you have a snipet of code to understand how i can implement this ?
Only the https://github.com/JetBrains/intellij-community/blob/2bb5f9a8563cc87aea464cdf45a74ad040060fff/plugins/devkit/intellij.devkit.git/src/KotlinPluginPrePushHandler.kt
Thanks very much.Unfortunately
PrePushHandler
doesn't work in my case because I want an event after a successful push. Is possible to listen to successful messages of git? So in prePushHandler get the push details object and then after the successful message run my logic.There's general notification listener, but it'll be unreliable for this purpose.
https://github.com/JetBrains/intellij-community/blob/2bb5f9a8563cc87aea464cdf45a74ad040060fff/platform/ide-core/src/com/intellij/notification/Notifications.java#L27
No, no explicit api to listen for the end of the push.
Thanks .. I tried to implement the notificaiton listener but it doesn work am i doing something wrong ?
I created a class Test and i implement the Notication interface and inside the notify method i add a message.
And then in the plugin xml i declare the listener
I see the notification from intellij in the right cornet but i cant see the message that i print
and
works for me.
You might want to check "Project vs Application" for listener/notification and whether test initialize IJ platform properly (and EP class is actually loaded).