BuildTree builds the tree objects and push its to the storer, the hash of the root tree is returned.
(idx *index.Index, opts *CommitOptions)
| 204 | // BuildTree builds the tree objects and push its to the storer, the hash |
| 205 | // of the root tree is returned. |
| 206 | func (h *buildTreeHelper) BuildTree(idx *index.Index, opts *CommitOptions) (plumbing.Hash, error) { |
| 207 | const rootNode = "" |
| 208 | h.trees = map[string]*object.Tree{rootNode: {}} |
| 209 | h.entries = map[string]*object.TreeEntry{} |
| 210 | |
| 211 | for _, e := range idx.Entries { |
| 212 | if err := h.commitIndexEntry(e); err != nil { |
| 213 | return plumbing.ZeroHash, err |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | return h.copyTreeToStorageRecursive(rootNode, h.trees[rootNode]) |
| 218 | } |
| 219 | |
| 220 | func (h *buildTreeHelper) commitIndexEntry(e *index.Entry) error { |
| 221 | parts := strings.Split(e.Name, "/") |
no test coverage detected