Skip to content

Commit

Permalink
Merge pull request #112 from chhsia0/bitbucketserver-pr-from-ref-updated
Browse files Browse the repository at this point in the history
Bitbucket Server: Add support for `pr:from_ref_updated` event.
  • Loading branch information
Toshik1978 authored Jul 17, 2020
2 parents 7a4edfc + 7c04644 commit 303483b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bitbucket-server/bitbucketserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ const (
RepositoryCommentEditedEvent Event = "repo:comment:edited"
RepositoryCommentDeletedEvent Event = "repo:comment:deleted"

PullRequestOpenedEvent Event = "pr:opened"
PullRequestModifiedEvent Event = "pr:modified"
PullRequestMergedEvent Event = "pr:merged"
PullRequestDeclinedEvent Event = "pr:declined"
PullRequestDeletedEvent Event = "pr:deleted"
PullRequestOpenedEvent Event = "pr:opened"
PullRequestFromReferenceUpdatedEvent Event = "pr:from_ref_updated"
PullRequestModifiedEvent Event = "pr:modified"
PullRequestMergedEvent Event = "pr:merged"
PullRequestDeclinedEvent Event = "pr:declined"
PullRequestDeletedEvent Event = "pr:deleted"

PullRequestReviewerUpdatedEvent Event = "pr:reviewer:updated"
PullRequestReviewerApprovedEvent Event = "pr:reviewer:approved"
Expand Down Expand Up @@ -168,6 +169,10 @@ func (hook *Webhook) Parse(r *http.Request, events ...Event) (interface{}, error
var pl PullRequestOpenedPayload
err = json.Unmarshal([]byte(payload), &pl)
return pl, err
case PullRequestFromReferenceUpdatedEvent:
var pl PullRequestFromReferenceUpdatedPayload
err = json.Unmarshal([]byte(payload), &pl)
return pl, err
case PullRequestModifiedEvent:
var pl PullRequestModifiedPayload
err = json.Unmarshal([]byte(payload), &pl)
Expand Down
8 changes: 8 additions & 0 deletions bitbucket-server/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ type PullRequestOpenedPayload struct {
PullRequest PullRequest `json:"pullRequest"`
}

type PullRequestFromReferenceUpdatedPayload struct {
Date Date `json:"date"`
EventKey Event `json:"eventKey"`
Actor User `json:"actor"`
PullRequest PullRequest `json:"pullRequest"`
PreviousFromHash string `json:"previousFromHash"`
}

type PullRequestModifiedPayload struct {
Date Date `json:"date"`
EventKey Event `json:"eventKey"`
Expand Down

0 comments on commit 303483b

Please sign in to comment.