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

revlist: ignore treeEntries that are submodules. #440

Merged
merged 1 commit into from
Jun 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plumbing/revlist/revlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"

"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/filemode"
"gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
)
Expand Down Expand Up @@ -121,6 +122,10 @@ func iterateCommitTrees(
return err
}

if e.Mode == filemode.Submodule {
continue
}

if seen[e.Hash] {
continue
}
Expand Down
20 changes: 19 additions & 1 deletion plumbing/revlist/revlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package revlist
import (
"testing"

"github.com/src-d/go-git-fixtures"
"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"
"gopkg.in/src-d/go-git.v4/storage/filesystem"

"github.com/src-d/go-git-fixtures"
. "gopkg.in/check.v1"
)

Expand Down Expand Up @@ -62,6 +62,24 @@ func (s *RevListSuite) commit(c *C, h plumbing.Hash) *object.Commit {
return commit
}

func (s *RevListSuite) TestRevListObjects_Submodules(c *C) {
submodules := map[string]bool{
"6ecf0ef2c2dffb796033e5a02219af86ec6584e5": true,
}

sto, err := filesystem.NewStorage(fixtures.ByTag("submodule").One().DotGit())
c.Assert(err, IsNil)

ref, err := storer.ResolveReference(sto, plumbing.HEAD)
c.Assert(err, IsNil)

revList, err := Objects(sto, []plumbing.Hash{ref.Hash()}, nil)
c.Assert(err, IsNil)
for _, h := range revList {
c.Assert(submodules[h.String()], Equals, false)
}
}

// ---
// | |\
// | | * b8e471f Creating changelog
Expand Down