Helper functions for GitHub integration
(item *models.Item, bold, dim *color.Color)
| 363 | // Helper functions for GitHub integration |
| 364 | |
| 365 | func showItemPRStatus(item *models.Item, bold, dim *color.Color) error { |
| 366 | pr := extractPRFromItem(item) |
| 367 | if pr == nil { |
| 368 | return fmt.Errorf("item %q has no linked PR", item.Slug) |
| 369 | } |
| 370 | |
| 371 | ref := cli.ItemRef(*item) |
| 372 | stateColor := prStateColor(pr.State) |
| 373 | |
| 374 | bold.Printf("%s %s\n", ref, item.Title) |
| 375 | fmt.Printf("PR #%d %s %s\n", pr.Number, stateColor.Sprint(pr.State), dim.Sprint(pr.URL)) |
| 376 | if pr.Branch != "" { |
| 377 | fmt.Printf("Branch: %s\n", dim.Sprint(pr.Branch)) |
| 378 | } |
| 379 | if pr.Repo != "" { |
| 380 | fmt.Printf("Repo: %s\n", dim.Sprint(pr.Repo)) |
| 381 | } |
| 382 | if pr.UpdatedAt != "" { |
| 383 | if t, err := time.Parse(time.RFC3339, pr.UpdatedAt); err == nil { |
| 384 | fmt.Printf("Updated: %s\n", dim.Sprint(relativeTimeStr(t))) |
| 385 | } |
| 386 | } |
| 387 | return nil |
| 388 | } |
| 389 | |
| 390 | func extractPRFromItem(item *models.Item) *GitHubPR { |
| 391 | if item == nil || item.CodeContext == nil || item.CodeContext.PullRequest == nil { |
no test coverage detected