// 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) }
// 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) }
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 }
// 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) }
// 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) }
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) } }