From 7c3eaa3ddfc19b5334634faa50b4570433402b19 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Mon, 8 Jun 2026 07:07:09 +0000 Subject: object/fetch: Port tag --- object/fetch/tag.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 object/fetch/tag.go (limited to 'object/fetch') diff --git a/object/fetch/tag.go b/object/fetch/tag.go new file mode 100644 index 00000000..422b818d --- /dev/null +++ b/object/fetch/tag.go @@ -0,0 +1,26 @@ +package fetch + +import ( + giterrors "lindenii.org/go/furgit/errors" + oid "lindenii.org/go/furgit/object/id" + "lindenii.org/go/furgit/object/stored" + "lindenii.org/go/furgit/object/tag" + "lindenii.org/go/furgit/object/typ" +) + +// ExactTag reads, parses, and wraps the tag at id. +// +// Labels: Life-Parent. +func (r *Fetcher) ExactTag(id oid.ObjectID) (*stored.Stored[*tag.Tag], error) { + parsed, err := r.parseObject(id) + if err != nil { + return nil, err + } + + tag, ok := parsed.(*tag.Tag) + if !ok { + return nil, &giterrors.ObjectTypeError{OID: id, Got: parsed.ObjectType(), Want: typ.TypeTag} + } + + return stored.New(id, tag), nil +} -- cgit v1.3.1-10-gc9f91