CreateTree creates a tree from the pending tree entries and clears the entry list. The new tree serves as the base tree for future Apply calls. CreateTree returns an error if there are no pending tree entires.
(ctx context.Context)
| 203 | // list. The new tree serves as the base tree for future Apply calls. |
| 204 | // CreateTree returns an error if there are no pending tree entires. |
| 205 | func (a *Applier) CreateTree(ctx context.Context) (*github.Tree, error) { |
| 206 | if len(a.entries) == 0 { |
| 207 | return nil, errors.New("no pending tree entries") |
| 208 | } |
| 209 | |
| 210 | tree, _, err := a.client.Git.CreateTree(ctx, a.owner, a.repo, a.tree, a.Entries()) |
| 211 | if err != nil { |
| 212 | return nil, err |
| 213 | } |
| 214 | |
| 215 | // Clear the tree cache here because we only cache trees that lead to file |
| 216 | // modifications, and any change creates a new (i.e. uncached) tree SHA |
| 217 | a.tree = tree.GetSHA() |
| 218 | a.treeCache = make(map[string]*github.Tree) |
| 219 | a.entries = make(map[string]*github.TreeEntry) |
| 220 | a.uncommitted = true |
| 221 | return tree, nil |
| 222 | } |
| 223 | |
| 224 | // Commit commits the latest tree, optionally using the details in tmpl and |
| 225 | // header. If there are pending tree entries, it calls CreateTree before |