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

Function main

example/commitpr/main.go:215–250  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

213}
214
215func main() {
216 flag.Parse()
217 token := os.Getenv("GITHUB_AUTH_TOKEN")
218 if token == "" {
219 log.Fatal("Unauthorized: No token present")
220 }
221 if *sourceOwner == "" || *sourceRepo == "" || *commitBranch == "" || *sourceFiles == "" || *authorName == "" || *authorEmail == "" {
222 log.Fatal("You need to specify a non-empty value for the flags `-source-owner`, `-source-repo`, `-commit-branch`, `-files`, `-author-name` and `-author-email`")
223 }
224 c, err := github.NewClient(github.WithAuthToken(token))
225 if err != nil {
226 log.Fatal(err)
227 }
228 client = c
229
230 ref, err := getRef()
231 if err != nil {
232 log.Fatalf("Unable to get/create the commit reference: %v", err)
233 }
234 if ref == nil {
235 log.Fatal("No error where returned but the reference is nil")
236 }
237
238 tree, err := getTree(ref)
239 if err != nil {
240 log.Fatalf("Unable to create the tree based on the provided files: %v", err)
241 }
242
243 if err := pushCommit(ref, tree); err != nil {
244 log.Fatalf("Unable to create the commit: %v", err)
245 }
246
247 if err := createPR(); err != nil {
248 log.Fatalf("Error while creating the pull request: %v", err)
249 }
250}

Callers

nothing calls this directly

Calls 6

NewClientFunction · 0.92
WithAuthTokenFunction · 0.92
getRefFunction · 0.85
getTreeFunction · 0.85
pushCommitFunction · 0.85
createPRFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…