Skip to content

Commit 88a1214

Browse files
Check directly if mergeable field is present (#5)
1 parent 0af6038 commit 88a1214

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

github/github.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,21 +392,25 @@ func (client *Client) PullRequestForSHA(repo *github.Repository, SHA string) (*g
392392
return nil, nil
393393
}
394394

395+
if pullRequest.Mergeable != nil {
396+
return pullRequest, nil
397+
}
398+
395399
ticker := time.NewTicker(5 * time.Second)
396400
for {
401+
select {
402+
case <-ticker.C:
403+
}
404+
397405
// polling for merge status (https://developer.github.com/v3/pulls/#get-a-single-pull-request)
398406
p, _, err := client.PullRequests.Get(client.Ctx, owner, name, pullRequest.GetNumber())
399407
if err != nil {
400408
return nil, errors.Wrapf(err, "cannot poll for PR merge status with head %s on %s", SHA, repo.GetFullName())
401409
}
402-
if p.GetMergeable() {
410+
if p.Mergeable != nil {
403411
pullRequest = p
404412
break
405413
}
406-
407-
select {
408-
case <-ticker.C:
409-
}
410414
}
411415

412416
return pullRequest, nil

0 commit comments

Comments
 (0)