Add Github wehbook management
Change-Id: I4b7a23a77838f345d65adf51877fab5978bd6055
diff --git a/server/git/git.go b/server/git/git.go
index 4cd7508..29cee16 100644
--- a/server/git/git.go
+++ b/server/git/git.go
@@ -69,6 +69,11 @@
RefreshAgentClone(agentName string) error
CleanupAgentClone(agentName string) error
CleanupAllClones() error
+
+ // Webhook operations (GitHub only)
+ ListWebhooks(ctx context.Context) ([]GitHubWebhookResponse, error)
+ CreateWebhook(ctx context.Context, webhookURL, secret string) (*GitHubWebhookResponse, error)
+ UpdateWebhook(ctx context.Context, webhookID int, webhookURL, secret string) (*GitHubWebhookResponse, error)
}
// Status represents the current state of the repository
@@ -679,6 +684,35 @@
return g.cloneManager.CleanupAllClones()
}
+// Webhook operations (GitHub only)
+
+// ListWebhooks lists existing webhooks for the repository
+func (g *Git) ListWebhooks(ctx context.Context) ([]GitHubWebhookResponse, error) {
+ webhookProvider, ok := g.prProvider.(WebhookProvider)
+ if !ok {
+ return nil, &GitError{Command: "ListWebhooks", Output: "webhook operations not supported by current provider"}
+ }
+ return webhookProvider.ListWebhooks(ctx)
+}
+
+// CreateWebhook creates a new webhook for the repository
+func (g *Git) CreateWebhook(ctx context.Context, webhookURL, secret string) (*GitHubWebhookResponse, error) {
+ webhookProvider, ok := g.prProvider.(WebhookProvider)
+ if !ok {
+ return nil, &GitError{Command: "CreateWebhook", Output: "webhook operations not supported by current provider"}
+ }
+ return webhookProvider.CreateWebhook(ctx, webhookURL, secret)
+}
+
+// UpdateWebhook updates an existing webhook
+func (g *Git) UpdateWebhook(ctx context.Context, webhookID int, webhookURL, secret string) (*GitHubWebhookResponse, error) {
+ webhookProvider, ok := g.prProvider.(WebhookProvider)
+ if !ok {
+ return nil, &GitError{Command: "UpdateWebhook", Output: "webhook operations not supported by current provider"}
+ }
+ return webhookProvider.UpdateWebhook(ctx, webhookID, webhookURL, secret)
+}
+
// Helper methods
func (g *Git) runCommand(cmd *exec.Cmd, command string) error {
@@ -982,3 +1016,10 @@
ClosePullRequest(ctx context.Context, id string) error
MergePullRequest(ctx context.Context, id string, options MergePullRequestOptions) error
}
+
+// WebhookProvider defines the interface for webhook operations
+type WebhookProvider interface {
+ ListWebhooks(ctx context.Context) ([]GitHubWebhookResponse, error)
+ CreateWebhook(ctx context.Context, webhookURL, secret string) (*GitHubWebhookResponse, error)
+ UpdateWebhook(ctx context.Context, webhookID int, webhookURL, secret string) (*GitHubWebhookResponse, error)
+}