From 691c3877b3267b023641173a60999e11e676a231 Mon Sep 17 00:00:00 2001 From: Mihail Kuzmich <32264674+kuzm1ch@users.noreply.github.com> Date: Thu, 28 Oct 2021 21:50:05 +0300 Subject: [PATCH] feat: add new bitbucket server webhook event type pr:from_ref_updated (#1866) --- server/controllers/events/events_controller.go | 2 +- server/events/event_parser.go | 4 +++- server/events/vcs/bitbucketserver/models.go | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server/controllers/events/events_controller.go b/server/controllers/events/events_controller.go index c94f2d648c..cd4d097aeb 100644 --- a/server/controllers/events/events_controller.go +++ b/server/controllers/events/events_controller.go @@ -205,7 +205,7 @@ func (e *VCSEventsController) handleBitbucketServerPost(w http.ResponseWriter, r } } switch eventType { - case bitbucketserver.PullCreatedHeader, bitbucketserver.PullMergedHeader, bitbucketserver.PullDeclinedHeader, bitbucketserver.PullDeletedHeader: + case bitbucketserver.PullCreatedHeader, bitbucketserver.PullFromRefUpdatedHeader, bitbucketserver.PullMergedHeader, bitbucketserver.PullDeclinedHeader, bitbucketserver.PullDeletedHeader: e.Logger.Debug("handling as pull request state changed event") e.handleBitbucketServerPullRequestEvent(w, eventType, body, reqID) return diff --git a/server/events/event_parser.go b/server/events/event_parser.go index 380ec3cd3f..0f487d17dd 100644 --- a/server/events/event_parser.go +++ b/server/events/event_parser.go @@ -636,7 +636,9 @@ func (e *EventParser) ParseGitlabMergeRequest(mr *gitlab.MergeRequest, baseRepo // event given the Bitbucket Server header. func (e *EventParser) GetBitbucketServerPullEventType(eventTypeHeader string) models.PullRequestEventType { switch eventTypeHeader { - case bitbucketserver.PullCreatedHeader: + // PullFromRefUpdatedHeader event occurs on OPEN state pull request + // so no additional checks are needed. + case bitbucketserver.PullCreatedHeader, bitbucketserver.PullFromRefUpdatedHeader: return models.OpenedPullEvent case bitbucketserver.PullMergedHeader, bitbucketserver.PullDeclinedHeader, bitbucketserver.PullDeletedHeader: return models.ClosedPullEvent diff --git a/server/events/vcs/bitbucketserver/models.go b/server/events/vcs/bitbucketserver/models.go index f9c34d4fc9..5646ca4256 100644 --- a/server/events/vcs/bitbucketserver/models.go +++ b/server/events/vcs/bitbucketserver/models.go @@ -3,6 +3,7 @@ package bitbucketserver const ( DiagnosticsPingHeader = "diagnostics:ping" PullCreatedHeader = "pr:opened" + PullFromRefUpdatedHeader = "pr:from_ref_updated" PullMergedHeader = "pr:merged" PullDeclinedHeader = "pr:declined" PullDeletedHeader = "pr:deleted"