aboutsummaryrefslogtreecommitdiffstats
path: root/repository/tree_entry.go
diff options
context:
space:
mode:
Diffstat (limited to 'repository/tree_entry.go')
-rw-r--r--repository/tree_entry.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/repository/tree_entry.go b/repository/tree_entry.go
index 8b3de8e2..6c5ec1a5 100644
--- a/repository/tree_entry.go
+++ b/repository/tree_entry.go
@@ -1,6 +1,7 @@
package repository
import (
+ "bytes"
"fmt"
"strings"
)
@@ -68,3 +69,34 @@ func ParseObjectType(mode, objType string) (ObjectType, error) {
return Unknown, fmt.Errorf("Unknown git object type %s %s", mode, objType)
}
}
+
+func prepareTreeEntries(entries []TreeEntry) bytes.Buffer {
+ var buffer bytes.Buffer
+
+ for _, entry := range entries {
+ buffer.WriteString(entry.Format())
+ }
+
+ return buffer
+}
+
+func readTreeEntries(s string) ([]TreeEntry, error) {
+ split := strings.Split(strings.TrimSpace(s), "\n")
+
+ casted := make([]TreeEntry, len(split))
+ for i, line := range split {
+ if line == "" {
+ continue
+ }
+
+ entry, err := ParseTreeEntry(line)
+
+ if err != nil {
+ return nil, err
+ }
+
+ casted[i] = entry
+ }
+
+ return casted, nil
+}