Skip to content

Commit

Permalink
+ [feat] add pullreq_comment_updated event
Browse files Browse the repository at this point in the history
  • Loading branch information
ysicing committed Dec 17, 2024
1 parent eaea3ae commit ddccc5c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
16 changes: 11 additions & 5 deletions gitfox/gitfox.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
30 changes: 30 additions & 0 deletions gitfox/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit ddccc5c

Please sign in to comment.