Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

Commit

Permalink
pluming: object, adjust to new API names in format/commitgraph
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Navara <[email protected]>
  • Loading branch information
filipnavara committed Apr 26, 2019
1 parent 14c17dc commit a47126b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
34 changes: 17 additions & 17 deletions plumbing/object/commitnode_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type graphCommitNode struct {
// Index of the node in the commit graph file
index int

node *commitgraph.Node
gci *graphCommitNodeIndex
commitData *commitgraph.CommitData
gci *graphCommitNodeIndex
}

// graphCommitNodeIndex is an index that can load CommitNode objects from both the commit
Expand All @@ -43,16 +43,16 @@ func (gci *graphCommitNodeIndex) Get(hash plumbing.Hash) (CommitNode, error) {
// Check the commit graph first
parentIndex, err := gci.commitGraph.GetIndexByHash(hash)
if err == nil {
parent, err := gci.commitGraph.GetNodeByIndex(parentIndex)
parent, err := gci.commitGraph.GetCommitDataByIndex(parentIndex)
if err != nil {
return nil, err
}

return &graphCommitNode{
hash: hash,
index: parentIndex,
node: parent,
gci: gci,
hash: hash,
index: parentIndex,
commitData: parent,
gci: gci,
}, nil
}

Expand All @@ -73,41 +73,41 @@ func (c *graphCommitNode) ID() plumbing.Hash {
}

func (c *graphCommitNode) Tree() (*Tree, error) {
return GetTree(c.gci.s, c.node.TreeHash)
return GetTree(c.gci.s, c.commitData.TreeHash)
}

func (c *graphCommitNode) CommitTime() time.Time {
return c.node.When
return c.commitData.When
}

func (c *graphCommitNode) NumParents() int {
return len(c.node.ParentIndexes)
return len(c.commitData.ParentIndexes)
}

func (c *graphCommitNode) ParentNodes() CommitNodeIter {
return newParentgraphCommitNodeIter(c)
}

func (c *graphCommitNode) ParentNode(i int) (CommitNode, error) {
if i < 0 || i >= len(c.node.ParentIndexes) {
if i < 0 || i >= len(c.commitData.ParentIndexes) {
return nil, ErrParentNotFound
}

parent, err := c.gci.commitGraph.GetNodeByIndex(c.node.ParentIndexes[i])
parent, err := c.gci.commitGraph.GetCommitDataByIndex(c.commitData.ParentIndexes[i])
if err != nil {
return nil, err
}

return &graphCommitNode{
hash: c.node.ParentHashes[i],
index: c.node.ParentIndexes[i],
node: parent,
gci: c.gci,
hash: c.commitData.ParentHashes[i],
index: c.commitData.ParentIndexes[i],
commitData: parent,
gci: c.gci,
}, nil
}

func (c *graphCommitNode) ParentHashes() []plumbing.Hash {
return c.node.ParentHashes
return c.commitData.ParentHashes
}

func (c *graphCommitNode) Commit() (*Commit, error) {
Expand Down
4 changes: 2 additions & 2 deletions plumbing/object/commitnode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"path"

. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git-fixtures.v3"
fixtures "gopkg.in/src-d/go-git-fixtures.v3"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/cache"
"gopkg.in/src-d/go-git.v4/plumbing/format/commitgraph"
Expand Down Expand Up @@ -131,7 +131,7 @@ func (s *CommitNodeSuite) TestMixedGraph(c *C) {
memoryIndex := commitgraph.NewMemoryIndex()
for i, hash := range fileIndex.Hashes() {
if hash.String() != "b9d69064b190e7aedccf84731ca1d917871f8a1c" {
node, err := fileIndex.GetNodeByIndex(i)
node, err := fileIndex.GetCommitDataByIndex(i)
c.Assert(err, IsNil)
memoryIndex.Add(hash, node)
}
Expand Down

0 comments on commit a47126b

Please sign in to comment.