createPR creates a pull request. Based on: https://pkg.go.dev/github.com/google/go-github/v88/github#example-PullRequestsService-Create
()
| 180 | |
| 181 | // createPR creates a pull request. Based on: https://pkg.go.dev/github.com/google/go-github/v88/github#example-PullRequestsService-Create |
| 182 | func createPR() (err error) { |
| 183 | if *prSubject == "" { |
| 184 | return errors.New("missing `-pr-title` flag; skipping PR creation") |
| 185 | } |
| 186 | |
| 187 | if *prRepoOwner != "" && *prRepoOwner != *sourceOwner { |
| 188 | *commitBranch = fmt.Sprintf("%v:%v", *sourceOwner, *commitBranch) |
| 189 | } else { |
| 190 | prRepoOwner = sourceOwner |
| 191 | } |
| 192 | |
| 193 | if *prRepo == "" { |
| 194 | prRepo = sourceRepo |
| 195 | } |
| 196 | |
| 197 | newPR := &github.NewPullRequest{ |
| 198 | Title: prSubject, |
| 199 | Head: commitBranch, |
| 200 | HeadRepo: repoBranch, |
| 201 | Base: prBranch, |
| 202 | Body: prDescription, |
| 203 | MaintainerCanModify: github.Ptr(true), |
| 204 | } |
| 205 | |
| 206 | pr, _, err := client.PullRequests.Create(ctx, *prRepoOwner, *prRepo, newPR) |
| 207 | if err != nil { |
| 208 | return err |
| 209 | } |
| 210 | |
| 211 | fmt.Printf("PR created: %v\n", pr.GetHTMLURL()) |
| 212 | return nil |
| 213 | } |
| 214 | |
| 215 | func main() { |
| 216 | flag.Parse() |
no test coverage detected
searching dependent graphs…