fetchPRInfo fetches detailed information about a pull request
(owner, repo string, prNumber int)
| 172 | |
| 173 | // fetchPRInfo fetches detailed information about a pull request |
| 174 | func fetchPRInfo(owner, repo string, prNumber int) (*PRInfo, error) { |
| 175 | prLog.Printf("Fetching PR info: %s/%s#%d", owner, repo, prNumber) |
| 176 | |
| 177 | // Fetch PR details using gh API |
| 178 | output, err := workflow.RunGH("Fetching pull request info...", "api", fmt.Sprintf("/repos/%s/%s/pulls/%d", owner, repo, prNumber), |
| 179 | "--jq", `{ |
| 180 | number: .number, |
| 181 | title: .title, |
| 182 | body: .body, |
| 183 | state: .state, |
| 184 | headSHA: .head.sha, |
| 185 | baseBranch: .base.ref, |
| 186 | headBranch: .head.ref, |
| 187 | sourceRepo: .head.repo.full_name, |
| 188 | targetRepo: .base.repo.full_name, |
| 189 | authorLogin: .user.login |
| 190 | }`) |
| 191 | if err != nil { |
| 192 | prLog.Printf("Failed to fetch PR info: %s", err) |
| 193 | return nil, fmt.Errorf("failed to fetch PR info: %w", err) |
| 194 | } |
| 195 | |
| 196 | var prInfo PRInfo |
| 197 | if err := json.Unmarshal(output, &prInfo); err != nil { |
| 198 | return nil, fmt.Errorf("failed to parse PR info: %w", err) |
| 199 | } |
| 200 | |
| 201 | prLog.Printf("Fetched PR #%d: state=%s, author=%s", prInfo.Number, prInfo.State, prInfo.AuthorLogin) |
| 202 | return &prInfo, nil |
| 203 | } |
| 204 | |
| 205 | // createPatchFromPR creates a git patch from the PR changes using gh pr diff |
| 206 | func createPatchFromPR(sourceOwner, sourceRepo string, prInfo *PRInfo, verbose bool) (string, error) { |
no test coverage detected