MCPcopy Index your code
hub / github.com/google/go-github / createPR

Function createPR

example/commitpr/main.go:182–213  ·  view source on GitHub ↗

createPR creates a pull request. Based on: https://pkg.go.dev/github.com/google/go-github/v88/github#example-PullRequestsService-Create

()

Source from the content-addressed store, hash-verified

180
181// createPR creates a pull request. Based on: https://pkg.go.dev/github.com/google/go-github/v88/github#example-PullRequestsService-Create
182func 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
215func main() {
216 flag.Parse()

Callers 1

mainFunction · 0.85

Calls 3

PtrFunction · 0.92
CreateMethod · 0.45
GetHTMLURLMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…