Пример #1
0
// create the repositories of the fixtures
func (s *SuiteTree) SetUpSuite(c *C) {
	fixtureRepos := [...]struct {
		url      string
		packfile string
	}{
		{"https://github.com/tyba/git-fixture.git", "formats/packfile/fixtures/git-fixture.ofs-delta"},
		{"https://github.com/cpcs499/Final_Pres_P.git", "formats/packfile/fixtures/Final_Pres_P.ofs-delta"},
		{"https://github.com/jamesob/desk.git", "formats/packfile/fixtures/jamesob-desk.pack"},
		{"https://github.com/spinnaker/spinnaker.git", "formats/packfile/fixtures/spinnaker-spinnaker.pack"},
		{"https://github.com/alcortesm/binary-relations.git", "formats/packfile/fixtures/alcortesm-binary-relations.pack"},
	}
	s.repos = make(map[string]*Repository, 0)
	for _, fixRepo := range fixtureRepos {
		s.repos[fixRepo.url] = NewPlainRepository()

		d, err := os.Open(fixRepo.packfile)
		c.Assert(err, IsNil)

		r := packfile.NewReader(d)
		r.Format = packfile.OFSDeltaFormat // TODO: how to know the format of a pack file ahead of time?

		_, err = r.Read(s.repos[fixRepo.url].Storage)
		c.Assert(err, IsNil)

		c.Assert(d.Close(), IsNil)
	}
}
Пример #2
0
// Pull connect and fetch the given branch from the given remote, the branch
// should be provided with the full path not only the abbreviation, eg.:
// "refs/heads/master"
func (r *Repository) Pull(remoteName, branch string) (err error) {
	remote, ok := r.Remotes[remoteName]
	if !ok {
		return fmt.Errorf("unable to find remote %q", remoteName)
	}

	if err := remote.Connect(); err != nil {
		return err
	}

	ref, err := remote.Ref(branch)
	if err != nil {
		return err
	}

	req := &common.GitUploadPackRequest{}
	req.Want(ref)

	reader, err := remote.Fetch(req)
	if err != nil {
		return err
	}
	defer func() {
		err = reader.Close()
	}()

	pr := packfile.NewReader(reader)
	if _, err = pr.Read(r.Storage); err != nil {
		return err
	}

	return nil
}
Пример #3
0
// create the repositories of the fixtures
func (s *ReferencesSuite) SetUpSuite(c *C) {
	s.repos = make(map[string]*Repository, 0)
	for _, fixRepo := range fixtureRepos {
		s.repos[fixRepo.url] = NewPlainRepository()

		d, err := os.Open(fixRepo.packfile)
		defer d.Close()
		c.Assert(err, IsNil)

		r := packfile.NewReader(d)
		r.Format = packfile.OFSDeltaFormat // TODO: how to know the format of a pack file ahead of time?

		_, err = r.Read(s.repos[fixRepo.url].Storage)
		c.Assert(err, IsNil)
	}
}
Пример #4
0
func (s *SuiteRemote) TestFetchDefaultBranch(c *C) {
	r, err := NewRemote(RepositoryFixture)
	r.upSrv = &MockGitUploadPackService{}

	c.Assert(err, IsNil)
	c.Assert(r.Connect(), IsNil)

	reader, err := r.FetchDefaultBranch()
	c.Assert(err, IsNil)

	pr := packfile.NewReader(reader)

	storage := core.NewRAWObjectStorage()
	_, err = pr.Read(storage)
	c.Assert(err, IsNil)
	c.Assert(storage.Objects, HasLen, 28)
}
Пример #5
0
// create the repositories of the fixtures
func (s *BlameCommon) SetUpSuite(c *C) {
	s.repos = make(map[string]*Repository, 0)
	for _, fixRepo := range fixtureRepos {
		repo := NewPlainRepository()
		repo.URL = fixRepo.url

		d, err := os.Open(fixRepo.packfile)
		c.Assert(err, IsNil)

		r := packfile.NewReader(d)
		// TODO: how to know the format of a pack file ahead of time?
		// Some info at:
		// https://codewords.recurse.com/issues/three/unpacking-git-packfiles
		r.Format = packfile.OFSDeltaFormat

		_, err = r.Read(repo.Storage)
		c.Assert(err, IsNil)

		c.Assert(d.Close(), IsNil)

		s.repos[fixRepo.url] = repo
	}
}
Пример #6
0
// create the repositories of the fixtures
func (s *SuiteCommit) SetUpSuite(c *C) {
	fixtureRepos := [...]struct {
		url      string
		packfile string
	}{
		{"https://github.com/tyba/git-fixture.git", "formats/packfile/fixtures/git-fixture.ofs-delta"},
	}
	s.repos = make(map[string]*Repository, 0)
	for _, fixRepo := range fixtureRepos {
		s.repos[fixRepo.url] = NewPlainRepository()

		d, err := os.Open(fixRepo.packfile)
		c.Assert(err, IsNil)

		r := packfile.NewReader(d)
		r.Format = packfile.OFSDeltaFormat // TODO: how to know the format of a pack file ahead of time?

		_, err = r.Read(s.repos[fixRepo.url].Storage)
		c.Assert(err, IsNil)

		c.Assert(d.Close(), IsNil)
	}
}
Пример #7
0
// create the repositories of the fixtures
func (s *SuiteFile) SetUpSuite(c *C) {
	fixtureRepos := [...]struct {
		url      string
		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 {
		s.repos[fixRepo.url] = NewPlainRepository()

		d, err := os.Open(fixRepo.packfile)
		c.Assert(err, IsNil)

		r := packfile.NewReader(d)
		r.Format = packfile.OFSDeltaFormat

		_, err = r.Read(s.repos[fixRepo.url].Storage)
		c.Assert(err, IsNil)

		c.Assert(d.Close(), IsNil)
	}
}