getTree generates the tree to commit based on the given files and the commit of the ref you got in getRef.
(ref *github.Reference)
| 96 | // getTree generates the tree to commit based on the given files and the commit |
| 97 | // of the ref you got in getRef. |
| 98 | func 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. |
no test coverage detected
searching dependent graphs…