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

Function getTree

example/commitpr/main.go:98–113  ·  view source on GitHub ↗

getTree generates the tree to commit based on the given files and the commit of the ref you got in getRef.

(ref *github.Reference)

Source from the content-addressed store, hash-verified

96// getTree generates the tree to commit based on the given files and the commit
97// of the ref you got in getRef.
98func getTree(ref *github.Reference) (tree *github.Tree, err error) {
99 // Create a tree with what to commit.
100 entries := []*github.TreeEntry{}
101
102 // Load each file into the tree.
103 for fileArg := range strings.SplitSeq(*sourceFiles, ",") {
104 file, content, err := getFileContent(fileArg)
105 if err != nil {
106 return nil, err
107 }
108 entries = append(entries, &github.TreeEntry{Path: &file, Type: github.Ptr("blob"), Content: github.Ptr(string(content)), Mode: github.Ptr("100644")})
109 }
110
111 tree, _, err = client.Git.CreateTree(ctx, *sourceOwner, *sourceRepo, *ref.Object.SHA, entries)
112 return tree, err
113}
114
115// getFileContent loads the local content of a file and return the target name
116// of the file in the target repository and its contents.

Callers 1

mainFunction · 0.85

Calls 3

PtrFunction · 0.92
getFileContentFunction · 0.85
CreateTreeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…