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.

1
9 comments

Hello,

Yes, there's no such API available anymore.
Could you clarify the use case? There might be another suitable workaround.

0

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

0

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 ?

0

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.

0

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.

0

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.

public class test implements Notifications {
@Override
public void notify(@NotNull Notification notification) {
System.out.println("my notification");
Notifications.super.notify(notification);
}
}

And then in the plugin xml i declare the listener 

<listener  class="network.radicle.jetbrains.radiclejetbrainsplugin.config.test" topic="com.intellij.notification.Notifications"/>

I see the notification from intellij in the right cornet but i cant see the message that i print 

0
package com.intellij.sample

import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.DumbAwareAction

class MyListener : com.intellij.notification.Notifications {
override fun notify(notification: Notification) {
println(notification.title)
}
}

class SendTestMessageAction : DumbAwareAction("Send Test Message") {
override fun actionPerformed(e: AnActionEvent) {
Notification("group", "Some title", "Some message", NotificationType.INFORMATION).notify(e.project)
}
}

and

<projectListeners>
<listener class="com.intellij.sample.MyListener"
topic="com.intellij.notification.Notifications"/>
</projectListeners>

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).

0

Please sign in to leave a comment.