Skip to content

Commit

Permalink
fix: cr
Browse files Browse the repository at this point in the history
Signed-off-by: Yvonnick Esnault <[email protected]>
  • Loading branch information
yesnault committed Feb 6, 2024
1 parent c94183b commit 4f6d5b4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion engine/api/v2_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func LoadWorkflowHooksWithRepositoryWebHooks(ctx context.Context, db gorp.SqlExe
filteredWorkflowHooks = append(filteredWorkflowHooks, w)
}
continue
case sdk.WorkflowHookEventPullRequest:
case sdk.WorkflowHookEventPullRequest, sdk.WorkflowHookEventPullRequestComment:
validBranch := sdk.IsValidHookRefs(ctx, w.Data.BranchFilter, strings.TrimPrefix(hookRequest.Ref, sdk.GitRefBranchPrefix))
validTag := sdk.IsValidHookRefs(ctx, w.Data.TagFilter, strings.TrimPrefix(hookRequest.Ref, sdk.GitRefTagPrefix))
validPath := sdk.IsValidHookPath(ctx, w.Data.PathFilter, hookRequest.Paths)
Expand Down
10 changes: 10 additions & 0 deletions engine/hooks/hook_repository_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ func (s *Service) extractDataFromBitbucketRequest(body []byte) (string, sdk.Hook
extractedData.Commit = request.PullRequest.FromRef.LatestCommit
extractedData.CDSEventName = sdk.WorkflowHookEventPullRequest
extractedData.CDSEventType = sdk.WorkflowHookEventPullRequestTypeOpened
case "pr:reopened":
extractedData.Ref = request.PullRequest.FromRef.ID
extractedData.Commit = request.PullRequest.FromRef.LatestCommit
extractedData.CDSEventName = sdk.WorkflowHookEventPullRequest
extractedData.CDSEventType = sdk.WorkflowHookEventPullRequestTypeReopened
case "pr:declined":
extractedData.Ref = request.PullRequest.FromRef.ID
extractedData.Commit = request.PullRequest.FromRef.LatestCommit
extractedData.CDSEventName = sdk.WorkflowHookEventPullRequest
extractedData.CDSEventType = sdk.WorkflowHookEventPullRequestTypeClosed
case "pr:from_ref_updated":
extractedData.Ref = request.PullRequest.FromRef.ID
extractedData.Commit = request.PullRequest.FromRef.LatestCommit
Expand Down
10 changes: 6 additions & 4 deletions sdk/hooks_repository_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ const (
WorkflowHookEventModelUpdate = "model_update"
WorkflowHookEventPush = "push"

WorkflowHookEventPullRequest = "pull_request"
WorkflowHookEventPullRequestTypeOpened = "opened"
WorkflowHookEventPullRequestTypeEdited = "edited"
WorkflowHookEventPullRequest = "pull_request"
WorkflowHookEventPullRequestTypeOpened = "opened"
WorkflowHookEventPullRequestTypeReopened = "reopened"
WorkflowHookEventPullRequestTypeClosed = "closed"
WorkflowHookEventPullRequestTypeEdited = "edited"

WorkflowHookEventPullRequestComment = "pull_request_comment"
WorkflowHookEventPullRequestCommentTypeCreated = "created"
Expand Down Expand Up @@ -77,7 +79,7 @@ type HookRepositoryEvent struct {
UUID string `json:"uuid"`
Created int64 `json:"created"`
EventName string `json:"event_name"` // WorkflowHookEventPush, sdk.WorkflowHookEventPullRequest
EventType string `json:"event_type"` // repo:refs_changed", "pr:opened", "pr:from_ref_updated"
EventType string `json:"event_type"` // created, deleted, edited, opened
VCSServerType string `json:"vcs_server_type"`
VCSServerName string `json:"vcs_server_name"`
RepositoryName string `json:"repository_name"`
Expand Down

0 comments on commit 4f6d5b4

Please sign in to comment.