in pkg/event_processor/bitbucket/bitbucket.go [100:137]
func (p *EventProcessor) processCommentEvent(ctx context.Context, body []byte, ns string) (*event_processor.EventInfo, error) {
bitbucketEvent := &event_processor.BitbucketCommentEvent{}
if err := json.Unmarshal(body, bitbucketEvent); err != nil {
return nil, fmt.Errorf("failed to unmarshal Bitbucket event: %w", err)
}
if bitbucketEvent.Repository.FullName == "" {
return nil, errors.New("bitbucket repository path empty")
}
repoPath := event_processor.ConvertRepositoryPath(bitbucketEvent.Repository.FullName)
codebase, err := event_processor.GetCodebaseByRepoPath(ctx, p.ksClient, ns, repoPath)
if err != nil {
return nil, fmt.Errorf("failed to get codebase by repo path: %w", err)
}
commitMessage, err := p.getPRLatestCommitMessage(ctx, codebase, bitbucketEvent.Repository.FullName, bitbucketEvent.PullRequest.ID)
if err != nil {
return nil, err
}
return &event_processor.EventInfo{
GitProvider: event_processor.GitProviderBitbucket,
RepoPath: repoPath,
TargetBranch: bitbucketEvent.PullRequest.Destination.Branch.Name,
Type: event_processor.EventTypeReviewComment,
Codebase: codebase,
HasPipelineRecheck: event_processor.ContainsPipelineRecheck(bitbucketEvent.Comment.Content.Raw),
PullRequest: &event_processor.PullRequest{
HeadSha: bitbucketEvent.PullRequest.Source.Commit.Hash,
Title: bitbucketEvent.PullRequest.Title,
HeadRef: bitbucketEvent.PullRequest.Source.Branch.Name,
ChangeNumber: bitbucketEvent.PullRequest.ID,
LastCommitMessage: commitMessage,
},
}, nil
}