(ref string, extraArgs []string)
| 66 | } |
| 67 | |
| 68 | func runDiffDirect(ref string, extraArgs []string) error { |
| 69 | ref = strings.TrimSpace(ref) |
| 70 | if ref == "" { |
| 71 | return fmt.Errorf("PR reference cannot be empty") |
| 72 | } |
| 73 | |
| 74 | includeComments := true |
| 75 | for _, arg := range extraArgs { |
| 76 | if strings.TrimSpace(arg) == "--no-comments" { |
| 77 | includeComments = false |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | owner, repo, prNumber, err := parsePRRef(ref) |
| 82 | if err != nil { |
| 83 | return err |
| 84 | } |
| 85 | |
| 86 | if _, err := exec.LookPath("gh"); err != nil { |
| 87 | return fmt.Errorf("gh CLI not found in PATH: %w", err) |
| 88 | } |
| 89 | |
| 90 | repoFull := fmt.Sprintf("%s/%s", owner, repo) |
| 91 | prRef := fmt.Sprintf("%d", prNumber) |
| 92 | |
| 93 | var out bytes.Buffer |
| 94 | |
| 95 | out.WriteString(fmt.Sprintf("# Pull Request: %s#%d\n\n", repoFull, prNumber)) |
| 96 | |
| 97 | prInfo, err := getPRInfo(repoFull, prRef) |
| 98 | if err != nil { |
| 99 | return err |
| 100 | } |
| 101 | |
| 102 | out.WriteString(fmt.Sprintf("## %s\n\n", prInfo.Title)) |
| 103 | out.WriteString(fmt.Sprintf("**Author:** %s\n", prInfo.Author.Login)) |
| 104 | out.WriteString(fmt.Sprintf("**State:** %s\n", prInfo.State)) |
| 105 | out.WriteString(fmt.Sprintf("**Base:** %s ← **Head:** %s\n", prInfo.BaseRefName, prInfo.HeadRefName)) |
| 106 | out.WriteString(fmt.Sprintf("**Stats:** +%d -%d across %d files\n\n", prInfo.Additions, prInfo.Deletions, prInfo.ChangedFiles)) |
| 107 | |
| 108 | if prInfo.Body != "" { |
| 109 | out.WriteString("## Description\n\n") |
| 110 | out.WriteString(prInfo.Body) |
| 111 | out.WriteString("\n\n") |
| 112 | } |
| 113 | |
| 114 | if includeComments { |
| 115 | if comments, err := getPRComments(repoFull, prRef); err == nil && len(comments) > 0 { |
| 116 | out.WriteString("## Comments\n\n") |
| 117 | for i, c := range comments { |
| 118 | out.WriteString(fmt.Sprintf("### Comment %d by %s\n\n", i+1, c.Author.Login)) |
| 119 | out.WriteString(c.Body) |
| 120 | out.WriteString("\n\n") |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | if reviews, err := getPRReviews(repoFull, prRef); err == nil && len(reviews) > 0 { |
| 125 | out.WriteString("## Reviews\n\n") |
no test coverage detected