Skip to content

Commit

Permalink
Merge pull request #4 from asecurityteam/add-reviewers
Browse files Browse the repository at this point in the history
fixing issue where current user is a default reviewer
  • Loading branch information
gcase555 committed Jun 21, 2024
2 parents cf69583 + 1f94161 commit 5046599
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/scm/bitbucketcloud/bitbucket_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,15 @@ func (bbc *BitbucketCloud) CreatePullRequest(ctx context.Context, repo scm.Repos
Owner: bbc.workspaces[0],
RepoSlug: splitRepoFullName[1],
}
currentUser, err := bbc.bbClient.User.Profile()
if err != nil {
return nil, err
}
defaultReviewers, _ := bbc.bbClient.Repositories.Repository.ListDefaultReviewers(repoOptions)
for _, reviewer := range defaultReviewers.DefaultReviewers {
newPR.Reviewers = append(newPR.Reviewers, reviewer.Uuid)
if currentUser.Uuid != reviewer.Uuid {
newPR.Reviewers = append(newPR.Reviewers, reviewer.Uuid)
}
}

if bbc.newOwner == "" {
Expand All @@ -85,7 +91,7 @@ func (bbc *BitbucketCloud) CreatePullRequest(ctx context.Context, repo scm.Repos
prOptions.SourceRepository = fmt.Sprintf("%s/%s", bbc.newOwner, repoOptions.RepoSlug)
}

_, err := bbc.bbClient.Repositories.PullRequests.Create(prOptions)
_, err = bbc.bbClient.Repositories.PullRequests.Create(prOptions)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 5046599

Please sign in to comment.