diff options
author | Alberto Cortés <alberto@sourced.tech> | 2016-01-08 16:04:29 +0100 |
---|---|---|
committer | Alberto Cortés <alberto@sourced.tech> | 2016-01-08 16:49:10 +0100 |
commit | 3ba036079b8e7a08302282b546cff6df628cb6db (patch) | |
tree | f220b82b1bd3aece0d0a4d0d5d38537c45ecea86 /file_test.go | |
parent | da5ab9de3e4c1bffa533108f46c5adc30929f7c2 (diff) | |
download | go-git-3ba036079b8e7a08302282b546cff6df628cb6db.tar.gz |
Ignore submodule dirs (empty directories without associated object), add empty dir test
Diffstat (limited to 'file_test.go')
-rw-r--r-- | file_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/file_test.go b/file_test.go index 8c22bb3..b5bdeac 100644 --- a/file_test.go +++ b/file_test.go @@ -22,6 +22,7 @@ func (s *SuiteFile) SetUpSuite(c *C) { packfile string }{ {"https://github.com/tyba/git-fixture.git", "formats/packfile/fixtures/git-fixture.ofs-delta"}, + {"https://github.com/cpcs499/Final_Pres_P", "formats/packfile/fixtures/Final_Pres_P.ofs-delta"}, } s.repos = make(map[string]*Repository, 0) for _, fixRepo := range fixtureRepos { @@ -131,3 +132,31 @@ func (s *SuiteFile) TestLines(c *C) { "subtest %d: commit=%s, path=%s", i, t.commit, t.path)) } } + +var ignoreEmptyDirEntriesTests = []struct { + repo string // the repo name as in localRepos + commit string // the commit to search for the file +}{ + { + "https://github.com/cpcs499/Final_Pres_P", + "70bade703ce556c2c7391a8065c45c943e8b6bc3", + // the Final dir in this commit is empty + }, +} + +// It is difficult to assert that we are ignoring an (empty) dir as even +// if we don't, no files will be found in it. +// +// At least this test has a high chance of panicking if +// we don't ignore empty dirs. +func (s *SuiteFile) TestIgnoreEmptyDirEntries(c *C) { + for i, t := range ignoreEmptyDirEntriesTests { + commit, err := s.repos[t.repo].Commit(core.NewHash(t.commit)) + c.Assert(err, IsNil, Commentf("subtest %d: %v (%s)", i, err, t.commit)) + + for file := range commit.Tree().Files() { + _ = file.Contents() + // this would probably panic if we are not ignoring empty dirs + } + } +} |