1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package fetch
import (
"fmt"
"lindenii.org/go/furgit/object"
oid "lindenii.org/go/furgit/object/id"
"lindenii.org/go/furgit/object/stored"
)
// ExactObject reads, parses, and wraps the object at id without constraining
// its concrete object kind.
//
// Labels: Life-Parent.
func (fetcher *Fetcher) ExactObject(id oid.ObjectID) (*stored.Stored[object.Object], error) {
parsed, err := fetcher.parseObject(id)
if err != nil {
return nil, err
}
return stored.New(id, parsed), nil
}
func (fetcher *Fetcher) parseObject(id oid.ObjectID) (object.Object, error) { //nolint:ireturn
ty, content, err := fetcher.store.ReadBytesContent(id)
if err != nil {
return nil, wrapObjectReadError(id, err)
}
parsed, err := object.ParseWithoutHeader(ty, content, id.ObjectFormat())
if err != nil {
return nil, fmt.Errorf("object/fetch: parse object %s (%s): %w", id, ty.Name(), err)
}
return parsed, nil
}
|