Skip to content

Commit e4b0b6e

Browse files
committed
use cached pr info
1 parent 423f492 commit e4b0b6e

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

cmd/view.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ func viewFull(cfg *config.Config, s *stack.Stack, currentBranch string) error {
174174
indicator := branchStatusIndicator(cfg, s, b)
175175

176176
prInfo := ""
177-
if clientErr == nil && repoErr == nil {
177+
if b.PullRequest != nil {
178+
if url := b.PullRequest.URL; url != "" {
179+
prInfo = " " + url
180+
}
181+
} else if clientErr == nil && repoErr == nil {
178182
pr, err := client.FindPRForBranch(b.Branch)
179183
if err == nil && pr != nil {
180184
prInfo = fmt.Sprintf(" https://github.com/%s/%s/pull/%d", repoOwner, repoName, pr.Number)
@@ -298,11 +302,16 @@ func viewWeb(cfg *config.Config, s *stack.Stack) error {
298302

299303
opened := 0
300304
for _, br := range s.Branches {
301-
pr, err := client.FindPRForBranch(br.Branch)
302-
if err != nil || pr == nil {
303-
continue
305+
var url string
306+
if br.PullRequest != nil && br.PullRequest.URL != "" {
307+
url = br.PullRequest.URL
308+
} else {
309+
pr, err := client.FindPRForBranch(br.Branch)
310+
if err != nil || pr == nil {
311+
continue
312+
}
313+
url = fmt.Sprintf("https://github.com/%s/%s/pull/%d", repo.Owner, repo.Name, pr.Number)
304314
}
305-
url := fmt.Sprintf("https://github.com/%s/%s/pull/%d", repo.Owner, repo.Name, pr.Number)
306315
if err := b.Browse(url); err != nil {
307316
cfg.Warningf("failed to open %s: %v", url, err)
308317
} else {

0 commit comments

Comments
 (0)