From ddccc5ccb8f629f4ce7c02078766e2f858b0bf74 Mon Sep 17 00:00:00 2001 From: ysicing Date: Tue, 17 Dec 2024 09:57:41 +0800 Subject: [PATCH] + [feat] add pullreq_comment_updated event --- gitfox/gitfox.go | 16 +++++++++++----- gitfox/types.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/gitfox/gitfox.go b/gitfox/gitfox.go index 73e3616..cc245cc 100644 --- a/gitfox/gitfox.go +++ b/gitfox/gitfox.go @@ -41,11 +41,13 @@ const ( TagDeletedEvent HookEventType = "tag_deleted" TagUpdatedEvent HookEventType = "tag_updated" - PullReqCreatedEvent HookEventType = "pullreq_created" - PullReqReopenedEvent HookEventType = "pullreq_reopened" - PullReqBranchUpdatedEvent HookEventType = "pullreq_branch_updated" - PullReqClosedEvent HookEventType = "pullreq_closed" - PullReqCommentCreatedEvent HookEventType = "pullreq_comment_created" + PullReqCreatedEvent HookEventType = "pullreq_created" + PullReqReopenedEvent HookEventType = "pullreq_reopened" + PullReqBranchUpdatedEvent HookEventType = "pullreq_branch_updated" + PullReqClosedEvent HookEventType = "pullreq_closed" + PullReqCommentCreatedEvent HookEventType = "pullreq_comment_created" + PullReqCommentUpdatedEvent HookEventType = "pullreq_comment_updated" + // PullReqCommentStatusUpdated HookEventType = "pullreq_comment_status_updated" PullReqMergedEvent HookEventType = "pullreq_merged" PullReqReviewerCreatedEvent HookEventType = "pullreq_reviewer_created" PullReqReviewerDeletedEvent HookEventType = "pullreq_reviewer_deleted" @@ -178,6 +180,10 @@ func (hook Webhook) Parse(r *http.Request, events ...HookEventType) (interface{} var pl PullReqCommentPayload err = json.Unmarshal([]byte(payload), &pl) return pl, err + case PullReqCommentUpdatedEvent: + var pl PullReqCommentUpdatedPayload + err = json.Unmarshal([]byte(payload), &pl) + return pl, err case PullReqMergedEvent: var pl PullReqMergedPayload err = json.Unmarshal([]byte(payload), &pl) diff --git a/gitfox/types.go b/gitfox/types.go index 3ae2f76..4f1e2c2 100644 --- a/gitfox/types.go +++ b/gitfox/types.go @@ -161,12 +161,33 @@ type PullReqCommentPayload struct { type PullReqCommentSegment struct { CommentInfo CommentInfo `json:"comment"` + *CodeCommentInfo +} + +// PullReqCommentUpdatedSegment contains details for pullreq text comment edited payloads for webhooks. +type PullReqCommentUpdatedSegment struct { + CommentInfo + *CodeCommentInfo } type CommentInfo struct { ID int64 `json:"id"` ParentID *int64 `json:"parent_id,omitempty"` Text string `json:"text"` + Created int64 `json:"created"` + Updated int64 `json:"updated"` + Kind string `json:"kind"` +} + +type CodeCommentInfo struct { + Outdated bool `json:"outdated"` + MergeBaseSHA string `json:"merge_base_sha"` + SourceSHA string `json:"source_sha"` + Path string `json:"path"` + LineNew int `json:"line_new"` + SpanNew int `json:"span_new"` + LineOld int `json:"line_old"` + SpanOld int `json:"span_old"` } type PullReqReviewerCreatedPayload PullReqReviewerChangedPayload @@ -214,3 +235,12 @@ type PullReqUpdatedPayload struct { ReferenceSegment PullReqUpdateSegment } + +// PullReqCommentUpdatedPayload describes the body of the pullreq comment create trigger. +type PullReqCommentUpdatedPayload struct { + BaseSegment + PullReqSegment + PullReqTargetReferenceSegment + ReferenceSegment + PullReqCommentSegment +}