Esempio n. 1
0
File: tag.go Progetto: src-d/go-git
// GetTag gets a tag from an object storer and decodes it.
func GetTag(s storer.EncodedObjectStorer, h plumbing.Hash) (*Tag, error) {
	o, err := s.EncodedObject(plumbing.TagObject, h)
	if err != nil {
		return nil, err
	}

	return DecodeTag(s, o)
}
Esempio n. 2
0
// GetCommit gets a commit from an object storer and decodes it.
func GetCommit(s storer.EncodedObjectStorer, h plumbing.Hash) (*Commit, error) {
	o, err := s.EncodedObject(plumbing.CommitObject, h)
	if err != nil {
		return nil, err
	}

	return DecodeCommit(s, o)
}
Esempio n. 3
0
func commitExists(s storer.EncodedObjectStorer, h plumbing.Hash) (bool, error) {
	_, err := s.EncodedObject(plumbing.CommitObject, h)
	if err == plumbing.ErrObjectNotFound {
		return false, nil
	}

	return true, err
}
Esempio n. 4
0
File: blob.go Progetto: src-d/go-git
// GetBlob gets a blob from an object storer and decodes it.
func GetBlob(s storer.EncodedObjectStorer, h plumbing.Hash) (*Blob, error) {
	o, err := s.EncodedObject(plumbing.BlobObject, h)
	if err != nil {
		return nil, err
	}

	return DecodeBlob(o)
}
Esempio n. 5
0
// GetObject gets an object from an object storer and decodes it.
func GetObject(s storer.EncodedObjectStorer, h plumbing.Hash) (Object, error) {
	o, err := s.EncodedObject(plumbing.AnyObject, h)
	if err != nil {
		return nil, err
	}

	return DecodeObject(s, o)
}
Esempio n. 6
0
func assertObjects(c *C, s storer.EncodedObjectStorer, expects []string) {

	i, err := s.IterEncodedObjects(plumbing.AnyObject)
	c.Assert(err, IsNil)

	var count int
	err = i.ForEach(func(plumbing.EncodedObject) error { count++; return nil })
	c.Assert(err, IsNil)
	c.Assert(count, Equals, len(expects))

	for _, exp := range expects {
		obt, err := s.EncodedObject(plumbing.AnyObject, plumbing.NewHash(exp))
		c.Assert(err, IsNil)
		c.Assert(obt.Hash().String(), Equals, exp)
	}
}