Beispiel #1
0
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
}
Beispiel #2
0
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)
}
Beispiel #3
0
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
}
Beispiel #4
0
func (s *BaseSuite) NewRepository(f *fixtures.Fixture) *Repository {
	r, err := NewFilesystemRepository(f.DotGit().Base())
	if err != nil {
		panic(err)
	}

	return r
}
Beispiel #5
0
func (s *BaseSuite) NewRepository(f *fixtures.Fixture) *Repository {
	storage, err := filesystem.NewStorage(f.DotGit())
	if err != nil {
		panic(err)
	}

	r, err := NewRepository(storage)
	if err != nil {
		panic(err)
	}

	return r
}
Beispiel #6
0
func (s *BaseSuite) GetLocalRepositoryURL(f *fixtures.Fixture) string {
	path := f.DotGit().Base()
	return fmt.Sprintf("file://%s", path)
}