aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--repository/repo.go49
-rw-r--r--repository/tree_entry.go32
2 files changed, 42 insertions, 39 deletions
diff --git a/repository/repo.go b/repository/repo.go
index 7a69a14f..806edace 100644
--- a/repository/repo.go
+++ b/repository/repo.go
@@ -2,9 +2,7 @@
package repository
import (
- "bytes"
"errors"
- "strings"
"github.com/MichaelMure/git-bug/util/lamport"
)
@@ -16,6 +14,14 @@ var (
ErrClockNotExist = errors.New("clock doesn't exist")
)
+// Repo represents a source code repository.
+type Repo interface {
+ RepoConfig
+ RepoKeyring
+ RepoCommon
+ RepoData
+}
+
// RepoConfig access the configuration of a repository
type RepoConfig interface {
// LocalConfig give access to the repository scoped configuration
@@ -46,12 +52,8 @@ type RepoCommon interface {
GetRemotes() (map[string]string, error)
}
-// Repo represents a source code repository.
-type Repo interface {
- RepoConfig
- RepoKeyring
- RepoCommon
-
+// RepoData give access to the git data storage
+type RepoData interface {
// FetchRefs fetch git refs from a remote
FetchRefs(remote string, refSpec string) (string, error)
@@ -122,37 +124,6 @@ type ClockLoader struct {
Witnesser func(repo ClockedRepo) error
}
-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
-}
-
// TestedRepo is an extended ClockedRepo with function for testing only
type TestedRepo interface {
ClockedRepo
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
+}