aboutsummaryrefslogtreecommitdiff
path: root/object/fetch/exact_commit.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-25 19:33:32 +0000
committerGravatar Runxi Yu2026-03-25 19:33:57 +0000
commit1aa5cad4c8d6455eeb1f10893549e18bcca11996 (patch)
tree31082a30bde08639fc764c52c3cf2283489f3302 /object/fetch/exact_commit.go
parentTODO: updates (diff)
signatureNo signature
object/fetch: Rename from object/resolve
Diffstat (limited to 'object/fetch/exact_commit.go')
-rw-r--r--object/fetch/exact_commit.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/object/fetch/exact_commit.go b/object/fetch/exact_commit.go
new file mode 100644
index 00000000..d3f9dee1
--- /dev/null
+++ b/object/fetch/exact_commit.go
@@ -0,0 +1,24 @@
+package fetch
+
+import (
+ "fmt"
+
+ "codeberg.org/lindenii/furgit/object/commit"
+ objectid "codeberg.org/lindenii/furgit/object/id"
+ "codeberg.org/lindenii/furgit/object/stored"
+)
+
+// ExactCommit reads, parses, and wraps the commit at id.
+func (r *Fetcher) ExactCommit(id objectid.ObjectID) (*stored.Stored[*commit.Commit], error) {
+ parsed, err := r.parseObject(id)
+ if err != nil {
+ return nil, err
+ }
+
+ commit, ok := parsed.(*commit.Commit)
+ if !ok {
+ return nil, fmt.Errorf("object/fetch: expected commit object %s, got %v", id, parsed.ObjectType())
+ }
+
+ return stored.New(id, commit), nil
+}