From f1f5184d1633b4cb83437033d4b81ab7abf66825 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 30 Jan 2025 11:23:30 -0800 Subject: [PATCH] Fix bug --- modules/webhook/type.go | 17 ++--------------- tests/integration/repo_webhook_test.go | 3 +++ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/modules/webhook/type.go b/modules/webhook/type.go index fbec8892722..281f7e653b2 100644 --- a/modules/webhook/type.go +++ b/modules/webhook/type.go @@ -38,14 +38,6 @@ const ( // Event returns the HookEventType as an event string func (h HookEventType) Event() string { switch h { - case HookEventCreate: - return "create" - case HookEventDelete: - return "delete" - case HookEventFork: - return "fork" - case HookEventPush: - return "push" case HookEventIssues, HookEventIssueAssign, HookEventIssueLabel, HookEventIssueMilestone: return "issues" case HookEventPullRequest, HookEventPullRequestAssign, HookEventPullRequestLabel, HookEventPullRequestMilestone, @@ -59,14 +51,9 @@ func (h HookEventType) Event() string { return "pull_request_rejected" case HookEventPullRequestReviewComment: return "pull_request_comment" - case HookEventWiki: - return "wiki" - case HookEventRepository: - return "repository" - case HookEventRelease: - return "release" + default: + return string(h) } - return "" } // HookType is the type of a webhook diff --git a/tests/integration/repo_webhook_test.go b/tests/integration/repo_webhook_test.go index 2f9a815fef4..5a50d7d4914 100644 --- a/tests/integration/repo_webhook_test.go +++ b/tests/integration/repo_webhook_test.go @@ -533,6 +533,9 @@ func Test_WebhookStatus(t *testing.T) { assert.Contains(t, r.Header["X-Github-Event-Type"], "status", "X-GitHub-Event-Type should contain status") assert.Contains(t, r.Header["X-Gitea-Event-Type"], "status", "X-Gitea-Event-Type should contain status") assert.Contains(t, r.Header["X-Gogs-Event-Type"], "status", "X-Gogs-Event-Type should contain status") + assert.Contains(t, r.Header["X-Github-Event"], "status", "X-GitHub-Event should contain status") + assert.Contains(t, r.Header["X-Gitea-Event"], "status", "X-Gitea-Event should contain status") + assert.Contains(t, r.Header["X-Gogs-Event"], "status", "X-Gogs-Event should contain status") content, _ := io.ReadAll(r.Body) var payload api.CommitStatusPayload err := json.Unmarshal(content, &payload)