diff options
author | Filip Navara <filip.navara@gmail.com> | 2019-05-03 11:52:53 +0200 |
---|---|---|
committer | Filip Navara <filip.navara@gmail.com> | 2019-05-03 11:52:53 +0200 |
commit | a661bca784d305e9df581302b725dc20fad8b995 (patch) | |
tree | c0547dc3ac78c16549c7ead0f2ea49c7d7f889d2 | |
parent | 79262fc996a067e062796754748d12de349aa5aa (diff) | |
download | go-git-a661bca784d305e9df581302b725dc20fad8b995.tar.gz |
Move CommitNode/CommitNodeIndex into separate object/commitgraph package
Signed-off-by: Filip Navara <filip.navara@gmail.com>
-rw-r--r-- | plumbing/object/commitgraph/commitnode.go (renamed from plumbing/object/commitnode.go) | 9 | ||||
-rw-r--r-- | plumbing/object/commitgraph/commitnode_graph.go (renamed from plumbing/object/commitnode_graph.go) | 17 | ||||
-rw-r--r-- | plumbing/object/commitgraph/commitnode_object.go (renamed from plumbing/object/commitnode_object.go) | 13 | ||||
-rw-r--r-- | plumbing/object/commitgraph/commitnode_test.go (renamed from plumbing/object/commitnode_test.go) | 2 | ||||
-rw-r--r-- | plumbing/object/commitgraph/commitnode_walker_ctime.go (renamed from plumbing/object/commitnode_walker_ctime.go) | 2 |
5 files changed, 23 insertions, 20 deletions
diff --git a/plumbing/object/commitnode.go b/plumbing/object/commitgraph/commitnode.go index ce25487..e218d32 100644 --- a/plumbing/object/commitnode.go +++ b/plumbing/object/commitgraph/commitnode.go @@ -1,10 +1,11 @@ -package object
+package commitgraph
import (
"io"
"time"
"gopkg.in/src-d/go-git.v4/plumbing"
+ "gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
)
@@ -14,7 +15,7 @@ type CommitNode interface { // ID returns the Commit object id referenced by the commit graph node.
ID() plumbing.Hash
// Tree returns the Tree referenced by the commit graph node.
- Tree() (*Tree, error)
+ Tree() (*object.Tree, error)
// CommitTime returns the Commiter.When time of the Commit referenced by the commit graph node.
CommitTime() time.Time
// NumParents returns the number of parents in a commit.
@@ -29,7 +30,7 @@ type CommitNode interface { // Objects with newer generation are not reachable from objects of older generation.
Generation() uint64
// Commit returns the full commit object from the node
- Commit() (*Commit, error)
+ Commit() (*object.Commit, error)
}
// CommitNodeIndex is generic interface encapsulating an index of CommitNode objects
@@ -59,7 +60,7 @@ func newParentgraphCommitNodeIter(node CommitNode) CommitNodeIter { // there are no more commits, it returns io.EOF.
func (iter *parentCommitNodeIter) Next() (CommitNode, error) {
obj, err := iter.node.ParentNode(iter.i)
- if err == ErrParentNotFound {
+ if err == object.ErrParentNotFound {
return nil, io.EOF
}
if err == nil {
diff --git a/plumbing/object/commitnode_graph.go b/plumbing/object/commitgraph/commitnode_graph.go index ac790ab..bd54e18 100644 --- a/plumbing/object/commitnode_graph.go +++ b/plumbing/object/commitgraph/commitnode_graph.go @@ -1,4 +1,4 @@ -package object
+package commitgraph
import (
"fmt"
@@ -6,6 +6,7 @@ import ( "gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/format/commitgraph"
+ "gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
)
@@ -57,7 +58,7 @@ func (gci *graphCommitNodeIndex) Get(hash plumbing.Hash) (CommitNode, error) { }
// Fallback to loading full commit object
- commit, err := GetCommit(gci.s, hash)
+ commit, err := object.GetCommit(gci.s, hash)
if err != nil {
return nil, err
}
@@ -72,8 +73,8 @@ func (c *graphCommitNode) ID() plumbing.Hash { return c.hash
}
-func (c *graphCommitNode) Tree() (*Tree, error) {
- return GetTree(c.gci.s, c.commitData.TreeHash)
+func (c *graphCommitNode) Tree() (*object.Tree, error) {
+ return object.GetTree(c.gci.s, c.commitData.TreeHash)
}
func (c *graphCommitNode) CommitTime() time.Time {
@@ -90,7 +91,7 @@ func (c *graphCommitNode) ParentNodes() CommitNodeIter { func (c *graphCommitNode) ParentNode(i int) (CommitNode, error) {
if i < 0 || i >= len(c.commitData.ParentIndexes) {
- return nil, ErrParentNotFound
+ return nil, object.ErrParentNotFound
}
parent, err := c.gci.commitGraph.GetCommitDataByIndex(c.commitData.ParentIndexes[i])
@@ -117,14 +118,14 @@ func (c *graphCommitNode) Generation() uint64 { return uint64(c.commitData.Generation)
}
-func (c *graphCommitNode) Commit() (*Commit, error) {
- return GetCommit(c.gci.s, c.hash)
+func (c *graphCommitNode) Commit() (*object.Commit, error) {
+ return object.GetCommit(c.gci.s, c.hash)
}
func (c *graphCommitNode) String() string {
return fmt.Sprintf(
"%s %s\nDate: %s",
plumbing.CommitObject, c.ID(),
- c.CommitTime().Format(DateFormat),
+ c.CommitTime().Format(object.DateFormat),
)
}
diff --git a/plumbing/object/commitnode_object.go b/plumbing/object/commitgraph/commitnode_object.go index 9ac42d2..2779a54 100644 --- a/plumbing/object/commitnode_object.go +++ b/plumbing/object/commitgraph/commitnode_object.go @@ -1,10 +1,11 @@ -package object
+package commitgraph
import (
"math"
"time"
"gopkg.in/src-d/go-git.v4/plumbing"
+ "gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
)
@@ -13,7 +14,7 @@ import ( // objectCommitNode implements the CommitNode interface.
type objectCommitNode struct {
nodeIndex CommitNodeIndex
- commit *Commit
+ commit *object.Commit
}
// NewObjectCommitNodeIndex returns CommitNodeIndex implementation that uses
@@ -23,7 +24,7 @@ func NewObjectCommitNodeIndex(s storer.EncodedObjectStorer) CommitNodeIndex { }
func (oci *objectCommitNodeIndex) Get(hash plumbing.Hash) (CommitNode, error) {
- commit, err := GetCommit(oci.s, hash)
+ commit, err := object.GetCommit(oci.s, hash)
if err != nil {
return nil, err
}
@@ -50,7 +51,7 @@ func (c *objectCommitNode) ID() plumbing.Hash { return c.commit.ID()
}
-func (c *objectCommitNode) Tree() (*Tree, error) {
+func (c *objectCommitNode) Tree() (*object.Tree, error) {
return c.commit.Tree()
}
@@ -64,7 +65,7 @@ func (c *objectCommitNode) ParentNodes() CommitNodeIter { func (c *objectCommitNode) ParentNode(i int) (CommitNode, error) {
if i < 0 || i >= len(c.commit.ParentHashes) {
- return nil, ErrParentNotFound
+ return nil, object.ErrParentNotFound
}
// Note: It's necessary to go through CommitNodeIndex here to ensure
@@ -84,6 +85,6 @@ func (c *objectCommitNode) Generation() uint64 { return math.MaxUint64
}
-func (c *objectCommitNode) Commit() (*Commit, error) {
+func (c *objectCommitNode) Commit() (*object.Commit, error) {
return c.commit, nil
}
diff --git a/plumbing/object/commitnode_test.go b/plumbing/object/commitgraph/commitnode_test.go index a295b8b..2a339c8 100644 --- a/plumbing/object/commitnode_test.go +++ b/plumbing/object/commitgraph/commitnode_test.go @@ -1,4 +1,4 @@ -package object
+package commitgraph
import (
"path"
diff --git a/plumbing/object/commitnode_walker_ctime.go b/plumbing/object/commitgraph/commitnode_walker_ctime.go index e55b4ad..f6a1b6a 100644 --- a/plumbing/object/commitnode_walker_ctime.go +++ b/plumbing/object/commitgraph/commitnode_walker_ctime.go @@ -1,4 +1,4 @@ -package object
+package commitgraph
import (
"io"
|