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

Function ExamplePullRequestsService_Create

github/examples_test.go:125–153  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

123}
124
125func ExamplePullRequestsService_Create() {
126 // In this example we're creating a PR and displaying the HTML url at the end.
127
128 // Note that authentication is needed here as you are performing a modification
129 // so you will need to modify the example to provide authentication to
130 // github.NewClient(). See the following documentation for more information
131 // on how to authenticate with the client:
132 // https://pkg.go.dev/github.com/google/go-github/v88/github#hdr-Authentication
133 client, err := github.NewClient()
134 if err != nil {
135 log.Fatalf("Error creating GitHub client: %v", err)
136 }
137
138 newPR := &github.NewPullRequest{
139 Title: github.Ptr("My awesome pull request"),
140 Head: github.Ptr("branch_to_merge"),
141 Base: github.Ptr("master"),
142 Body: github.Ptr("This is the description of the PR created with the package `github.com/google/go-github/github`"),
143 MaintainerCanModify: github.Ptr(true),
144 }
145
146 ctx := context.Background()
147 pr, _, err := client.PullRequests.Create(ctx, "myOrganization", "myRepository", newPR)
148 if err != nil {
149 log.Fatalf("Error creating pull request: %v", err)
150 }
151
152 fmt.Printf("PR created: %v\n", pr.GetHTMLURL())
153}
154
155func ExampleTeamsService_ListTeams() {
156 // This example shows how to get a team ID corresponding to a given team name.

Callers

nothing calls this directly

Calls 4

NewClientFunction · 0.92
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…