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

Function getFileContent

example/commitpr/main.go:117–133  ·  view source on GitHub ↗

getFileContent loads the local content of a file and return the target name of the file in the target repository and its contents.

(fileArg string)

Source from the content-addressed store, hash-verified

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.
117func getFileContent(fileArg string) (targetName string, b []byte, err error) {
118 var localFile string
119 files := strings.Split(fileArg, ":")
120 switch {
121 case len(files) < 1:
122 return "", nil, errors.New("empty `-files` parameter")
123 case len(files) == 1:
124 localFile = files[0]
125 targetName = files[0]
126 default:
127 localFile = files[0]
128 targetName = files[1]
129 }
130
131 b, err = os.ReadFile(localFile)
132 return targetName, b, err
133}
134
135// pushCommit creates the commit in the given reference using the given tree.
136func pushCommit(ref *github.Reference, tree *github.Tree) (err error) {

Callers 1

getTreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…