示例#1
0
文件: tag.go 项目: 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)
}
示例#2
0
文件: commit.go 项目: src-d/go-git
// 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)
}
示例#3
0
文件: remote.go 项目: src-d/go-git
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
}
示例#4
0
文件: blob.go 项目: 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)
}
示例#5
0
文件: object.go 项目: src-d/go-git
// 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)
}
示例#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)
	}
}