@@ -105,28 +105,30 @@ func (b *Client) HidePrevCommandComments(repo models.Repo, pullNum int, command
105
105
}
106
106
107
107
// PullIsApproved returns true if the merge request was approved.
108
- func (b * Client ) PullIsApproved (repo models.Repo , pull models.PullRequest ) (bool , error ) {
108
+ func (b * Client ) PullIsApproved (repo models.Repo , pull models.PullRequest ) (approvalStatus models. ApprovalStatus , err error ) {
109
109
path := fmt .Sprintf ("%s/2.0/repositories/%s/pullrequests/%d" , b .BaseURL , repo .FullName , pull .Num )
110
110
resp , err := b .makeRequest ("GET" , path , nil )
111
111
if err != nil {
112
- return false , err
112
+ return approvalStatus , err
113
113
}
114
114
var pullResp PullRequest
115
115
if err := json .Unmarshal (resp , & pullResp ); err != nil {
116
- return false , errors .Wrapf (err , "Could not parse response %q" , string (resp ))
116
+ return approvalStatus , errors .Wrapf (err , "Could not parse response %q" , string (resp ))
117
117
}
118
118
if err := validator .New ().Struct (pullResp ); err != nil {
119
- return false , errors .Wrapf (err , "API response %q was missing fields" , string (resp ))
119
+ return approvalStatus , errors .Wrapf (err , "API response %q was missing fields" , string (resp ))
120
120
}
121
121
authorUUID := * pullResp .Author .UUID
122
122
for _ , participant := range pullResp .Participants {
123
123
// Bitbucket allows the author to approve their own pull request. This
124
124
// defeats the purpose of approvals so we don't count that approval.
125
125
if * participant .Approved && * participant .User .UUID != authorUUID {
126
- return true , nil
126
+ return models.ApprovalStatus {
127
+ IsApproved : true ,
128
+ }, nil
127
129
}
128
130
}
129
- return false , nil
131
+ return approvalStatus , nil
130
132
}
131
133
132
134
// PullIsMergeable returns true if the merge request has no conflicts and can be merged.
0 commit comments