@@ -4,32 +4,41 @@ import (
44 "fmt"
55
66 "github.com/google/go-github/v49/github"
7+ log "github.com/sirupsen/logrus"
78)
89
910// GetPrInfos need the PullRequest-Number
1011func (ghrc * GitHubRichClient ) GetPrInfos (prNumber int , mergeCommitSha string ) (prInfos * github.PullRequest , err error ) {
1112 if prNumber != 0 {
13+
1214 prInfos , _ , err = ghrc .Client .PullRequests .Get (ctx , ghrc .Owner , ghrc .Repository , prNumber )
1315 if err != nil {
1416 return nil , fmt .Errorf ("could not load any information about the given pull request %d: %v" , prNumber , err )
1517 }
16- }
17- if mergeCommitSha != "" && prNumber == 0 {
18+ log .Infof ("found pull request '%s' with given number %d" , * prInfos .Title , prNumber )
19+
20+ return
21+ } else if mergeCommitSha != "" {
22+
23+ log .Infoln ("listing pull requests to compare with merge commit sha" )
1824 prOpts := github.PullRequestListOptions {
1925 State : "all" ,
2026 Sort : "updated" ,
2127 Direction : "desc" ,
2228 ListOptions : github.ListOptions {
23- PerPage : 10 ,
29+ PerPage : 50 ,
2430 },
2531 }
2632 pullRequests , _ , err := ghrc .Client .PullRequests .List (ctx , ghrc .Owner , ghrc .Repository , & prOpts )
2733 if err != nil {
2834 return nil , fmt .Errorf ("could not load any information about the given pull request %d: %v" , prNumber , err )
2935 }
36+
37+ log .Infof ("listed %d pull requests, searching for maching mergeCommitSha" , len (pullRequests ))
3038 var found int = 0
3139 for _ , pr := range pullRequests {
3240 if pr .GetMergeCommitSHA () == mergeCommitSha {
41+ log .Infof ("found matching pull requests with number %d, and mergeCommitSha %s" , * pr .Number , * pr .MergeCommitSHA )
3342 prInfos = pr
3443 found = found + 1
3544 }
0 commit comments