diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-01-08 17:01:36 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-01-08 17:01:36 +0100 |
commit | cebec78608e7913b8c843390237fd609069022ae (patch) | |
tree | f220b82b1bd3aece0d0a4d0d5d38537c45ecea86 /file_test.go | |
parent | da5ab9de3e4c1bffa533108f46c5adc30929f7c2 (diff) | |
parent | 3ba036079b8e7a08302282b546cff6df628cb6db (diff) | |
download | go-git-cebec78608e7913b8c843390237fd609069022ae.tar.gz |
Merge pull request #11 from alcortesm/ignore-submodulesv2.1.1
Ignore submodule dirs (empty directories without associated object)
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 + } + } +} |