diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-11 20:35:06 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-11 20:35:06 +0200 |
commit | 58fe211f1b0e4863b425542d2fad15803276fd66 (patch) | |
tree | c200b6317b7b1c77c312faa411ab39e6e4468967 /fixtures | |
parent | 6f1d1e00a7c615209cf6b25e314d033bda3b5d09 (diff) | |
download | go-git-58fe211f1b0e4863b425542d2fad15803276fd66.tar.gz |
format: packfile fix ReadObjectAt without decode
Diffstat (limited to 'fixtures')
-rw-r--r-- | fixtures/fixtures.go | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/fixtures/fixtures.go b/fixtures/fixtures.go index 59cbd2a..8e1c0ed 100644 --- a/fixtures/fixtures.go +++ b/fixtures/fixtures.go @@ -17,7 +17,9 @@ var RootFolder = "" const DataFolder = "data" -var fixtures = []*Fixture{{ +var folders []string + +var fixtures = Fixtures{{ Tags: []string{"packfile", "ofs-delta", ".git"}, URL: "https://github.com/git-fixtures/basic", Head: core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), @@ -25,10 +27,11 @@ var fixtures = []*Fixture{{ DotGitHash: core.NewHash("0a00a25543e6d732dbf4e8e9fec55c8e65fc4e8d"), ObjectsCount: 31, }, { - Tags: []string{"packfile", "ref-delta"}, + Tags: []string{"packfile", "ref-delta", ".git"}, URL: "https://github.com/git-fixtures/basic", Head: core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), PackfileHash: core.NewHash("c544593473465e6315ad4182d04d366c4592b829"), + DotGitHash: core.NewHash("7cbde0ca02f13aedd5ec8b358ca17b1c0bf5ee64"), ObjectsCount: 31, }, { Tags: []string{".git", "unpacked", "multi-packfile"}, @@ -51,27 +54,11 @@ func Basic() Fixtures { } func ByURL(url string) Fixtures { - r := make(Fixtures, 0) - for _, f := range fixtures { - if f.URL == url { - r = append(r, f) - } - } - - return r + return fixtures.ByURL(url) } func ByTag(tag string) Fixtures { - r := make(Fixtures, 0) - for _, f := range fixtures { - for _, t := range f.Tags { - if t == tag { - r = append(r, f) - } - } - } - - return r + return fixtures.ByTag(tag) } type Fixture struct { @@ -83,6 +70,16 @@ type Fixture struct { ObjectsCount int32 } +func (f *Fixture) Is(tag string) bool { + for _, t := range f.Tags { + if t == tag { + return true + } + } + + return false +} + func (f *Fixture) Packfile() io.ReadSeeker { fn := filepath.Join(RootFolder, DataFolder, fmt.Sprintf("pack-%s.pack", f.PackfileHash)) file, err := os.Open(fn) @@ -109,6 +106,8 @@ func (f *Fixture) DotGit() fs.Filesystem { if err != nil { panic(err) } + + folders = append(folders, path) return fs.NewOS(path) } @@ -125,14 +124,23 @@ func (g Fixtures) One() *Fixture { return g[0] } -func (g Fixtures) ByTag(tag string) *Fixture { +func (g Fixtures) ByTag(tag string) Fixtures { + r := make(Fixtures, 0) for _, f := range g { - for _, t := range f.Tags { - if t == tag { - return f - } + if f.Is(tag) { + r = append(r, f) } } - return nil + return r +} +func (g Fixtures) ByURL(url string) Fixtures { + r := make(Fixtures, 0) + for _, f := range g { + if f.URL == url { + r = append(r, f) + } + } + + return r } |