func (s *SendPackSuite) sendPackNoCheck(c *C, ep transport.Endpoint, req *packp.ReferenceUpdateRequest, fixture *fixtures.Fixture, callAdvertisedReferences bool) (*packp.ReportStatus, error) { url := "" if fixture != nil { url = fixture.URL } comment := Commentf( "failed with ep=%s fixture=%s callAdvertisedReferences=%s", ep.String(), url, callAdvertisedReferences, ) r, err := s.Client.NewSendPackSession(ep) c.Assert(err, IsNil, comment) defer func() { c.Assert(r.Close(), IsNil, comment) }() if callAdvertisedReferences { info, err := r.AdvertisedReferences() c.Assert(err, IsNil, comment) c.Assert(info, NotNil, comment) } if fixture != nil { c.Assert(fixture.Packfile(), NotNil) req.Packfile = fixture.Packfile() } else { req.Packfile = s.emptyPackfile() } return r.SendPack(req) }
func (s *DiffTreeSuite) storageFromPackfile(f *fixtures.Fixture) storer.EncodedObjectStorer { sto, ok := s.cache[f.URL] if ok { return sto } sto = memory.NewStorage() pf := f.Packfile() defer pf.Close() n := packfile.NewScanner(pf) d, err := packfile.NewDecoder(n, sto) if err != nil { panic(err) } _, err = d.Decode() if err != nil { panic(err) } s.cache[f.URL] = sto return sto }
func (s *BaseSuite) NewRepositoryFromPackfile(f *fixtures.Fixture) *Repository { h := f.PackfileHash.String() if r, ok := s.cache[h]; ok { return r } r := NewMemoryRepository() p := f.Packfile() defer p.Close() n := packfile.NewScanner(p) d, err := packfile.NewDecoder(n, r.s) if err != nil { panic(err) } _, err = d.Decode() if err != nil { panic(err) } s.cache[h] = r return r }