From 676d0e6766e9af0574485dfac9a5d8ddf933ab03 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 17 May 2026 14:45:40 +0000 Subject: object: Serialize -> Bytes --- commitquery/queries_is_ancestor_unit_test.go | 4 ++-- commitquery/queries_merge_bases_unit_test.go | 4 ++-- object/blob/serialize.go | 10 +++++----- object/blob/serialize_test.go | 4 ++-- object/commit/serialize.go | 10 +++++----- object/commit/serialize_test.go | 4 ++-- object/object.go | 4 ++-- object/tag/serialize.go | 10 +++++----- object/tag/serialize_test.go | 4 ++-- object/tree/serialize.go | 10 +++++----- object/tree/serialize_test.go | 4 ++-- reachability/unit_test.go | 4 ++-- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/commitquery/queries_is_ancestor_unit_test.go b/commitquery/queries_is_ancestor_unit_test.go index 002c49ae..75a4b00c 100644 --- a/commitquery/queries_is_ancestor_unit_test.go +++ b/commitquery/queries_is_ancestor_unit_test.go @@ -42,9 +42,9 @@ func ancestorTagBody(target objectid.ObjectID, targetType objecttype.Type) []byt func mustSerializeAncestorTree(tb testing.TB, tree *objecttree.Tree) []byte { tb.Helper() - body, err := tree.SerializeWithoutHeader() + body, err := tree.BytesWithoutHeader() if err != nil { - tb.Fatalf("SerializeWithoutHeader: %v", err) + tb.Fatalf("BytesWithoutHeader: %v", err) } return body diff --git a/commitquery/queries_merge_bases_unit_test.go b/commitquery/queries_merge_bases_unit_test.go index 3e302536..3772f882 100644 --- a/commitquery/queries_merge_bases_unit_test.go +++ b/commitquery/queries_merge_bases_unit_test.go @@ -60,9 +60,9 @@ func containsID(set map[objectid.ObjectID]struct{}, id objectid.ObjectID) bool { func mustSerializeTree(tb testing.TB, tree *tree.Tree) []byte { tb.Helper() - body, err := tree.SerializeWithoutHeader() + body, err := tree.BytesWithoutHeader() if err != nil { - tb.Fatalf("SerializeWithoutHeader: %v", err) + tb.Fatalf("BytesWithoutHeader: %v", err) } return body diff --git a/object/blob/serialize.go b/object/blob/serialize.go index 80cce8dc..5594b200 100644 --- a/object/blob/serialize.go +++ b/object/blob/serialize.go @@ -7,14 +7,14 @@ import ( objecttype "codeberg.org/lindenii/furgit/object/type" ) -// SerializeWithoutHeader renders the raw blob body bytes. -func (blob *Blob) SerializeWithoutHeader() ([]byte, error) { +// BytesWithoutHeader renders the raw blob body bytes. +func (blob *Blob) BytesWithoutHeader() ([]byte, error) { return append([]byte(nil), blob.Data...), nil } -// SerializeWithHeader renders the raw object (header + body). -func (blob *Blob) SerializeWithHeader() ([]byte, error) { - body, err := blob.SerializeWithoutHeader() +// BytesWithHeader renders the raw object (header + body). +func (blob *Blob) BytesWithHeader() ([]byte, error) { + body, err := blob.BytesWithoutHeader() if err != nil { return nil, err } diff --git a/object/blob/serialize_test.go b/object/blob/serialize_test.go index 4292abad..99725eaf 100644 --- a/object/blob/serialize_test.go +++ b/object/blob/serialize_test.go @@ -17,9 +17,9 @@ func TestBlobSerialize(t *testing.T) { obj := &blob.Blob{Data: body} - rawObj, err := obj.SerializeWithHeader() + rawObj, err := obj.BytesWithHeader() if err != nil { - t.Fatalf("SerializeWithHeader: %v", err) + t.Fatalf("BytesWithHeader: %v", err) } gotID := algo.Sum(rawObj) diff --git a/object/commit/serialize.go b/object/commit/serialize.go index 3f141550..0642d656 100644 --- a/object/commit/serialize.go +++ b/object/commit/serialize.go @@ -9,8 +9,8 @@ import ( objecttype "codeberg.org/lindenii/furgit/object/type" ) -// SerializeWithoutHeader renders the raw commit body bytes. -func (commit *Commit) SerializeWithoutHeader() ([]byte, error) { +// BytesWithoutHeader renders the raw commit body bytes. +func (commit *Commit) BytesWithoutHeader() ([]byte, error) { var buf bytes.Buffer if commit.Tree.Algorithm().Size() == 0 { @@ -64,9 +64,9 @@ func (commit *Commit) SerializeWithoutHeader() ([]byte, error) { return buf.Bytes(), nil } -// SerializeWithHeader renders the raw object (header + body). -func (commit *Commit) SerializeWithHeader() ([]byte, error) { - body, err := commit.SerializeWithoutHeader() +// BytesWithHeader renders the raw object (header + body). +func (commit *Commit) BytesWithHeader() ([]byte, error) { + body, err := commit.BytesWithoutHeader() if err != nil { return nil, err } diff --git a/object/commit/serialize_test.go b/object/commit/serialize_test.go index e58a8078..6a3486cd 100644 --- a/object/commit/serialize_test.go +++ b/object/commit/serialize_test.go @@ -21,9 +21,9 @@ func TestCommitSerialize(t *testing.T) { t.Fatalf("ParseCommit: %v", err) } - rawObj, err := parsed.SerializeWithHeader() + rawObj, err := parsed.BytesWithHeader() if err != nil { - t.Fatalf("SerializeWithHeader: %v", err) + t.Fatalf("BytesWithHeader: %v", err) } gotID := algo.Sum(rawObj) diff --git a/object/object.go b/object/object.go index d1b1bc4f..2021a3de 100644 --- a/object/object.go +++ b/object/object.go @@ -5,6 +5,6 @@ import objecttype "codeberg.org/lindenii/furgit/object/type" // Object is a Git object. type Object interface { ObjectType() objecttype.Type - SerializeWithoutHeader() ([]byte, error) - SerializeWithHeader() ([]byte, error) + BytesWithoutHeader() ([]byte, error) + BytesWithHeader() ([]byte, error) } diff --git a/object/tag/serialize.go b/object/tag/serialize.go index 4f9d6664..43fad522 100644 --- a/object/tag/serialize.go +++ b/object/tag/serialize.go @@ -9,8 +9,8 @@ import ( objecttype "codeberg.org/lindenii/furgit/object/type" ) -// SerializeWithoutHeader renders the raw tag body bytes. -func (tag *Tag) SerializeWithoutHeader() ([]byte, error) { +// BytesWithoutHeader renders the raw tag body bytes. +func (tag *Tag) BytesWithoutHeader() ([]byte, error) { if tag.Target.Algorithm().Size() == 0 { return nil, errors.New("object: tag: missing target id") } @@ -48,9 +48,9 @@ func (tag *Tag) SerializeWithoutHeader() ([]byte, error) { return buf.Bytes(), nil } -// SerializeWithHeader renders the raw object (header + body). -func (tag *Tag) SerializeWithHeader() ([]byte, error) { - body, err := tag.SerializeWithoutHeader() +// BytesWithHeader renders the raw object (header + body). +func (tag *Tag) BytesWithHeader() ([]byte, error) { + body, err := tag.BytesWithoutHeader() if err != nil { return nil, err } diff --git a/object/tag/serialize_test.go b/object/tag/serialize_test.go index a1311c39..3a87e5ad 100644 --- a/object/tag/serialize_test.go +++ b/object/tag/serialize_test.go @@ -22,9 +22,9 @@ func TestTagSerialize(t *testing.T) { t.Fatalf("ParseTag: %v", err) } - rawObj, err := parsed.SerializeWithHeader() + rawObj, err := parsed.BytesWithHeader() if err != nil { - t.Fatalf("SerializeWithHeader: %v", err) + t.Fatalf("BytesWithHeader: %v", err) } gotID := algo.Sum(rawObj) diff --git a/object/tree/serialize.go b/object/tree/serialize.go index 69deacda..922cd145 100644 --- a/object/tree/serialize.go +++ b/object/tree/serialize.go @@ -8,8 +8,8 @@ import ( objecttype "codeberg.org/lindenii/furgit/object/type" ) -// SerializeWithoutHeader renders the raw tree body bytes. -func (tree *Tree) SerializeWithoutHeader() ([]byte, error) { +// BytesWithoutHeader renders the raw tree body bytes. +func (tree *Tree) BytesWithoutHeader() ([]byte, error) { var bodyLen int for _, entry := range tree.Entries { @@ -35,9 +35,9 @@ func (tree *Tree) SerializeWithoutHeader() ([]byte, error) { return body, nil } -// SerializeWithHeader renders the raw object (header + body). -func (tree *Tree) SerializeWithHeader() ([]byte, error) { - body, err := tree.SerializeWithoutHeader() +// BytesWithHeader renders the raw object (header + body). +func (tree *Tree) BytesWithHeader() ([]byte, error) { + body, err := tree.BytesWithoutHeader() if err != nil { return nil, err } diff --git a/object/tree/serialize_test.go b/object/tree/serialize_test.go index 9c9a2f1c..f7bc64b6 100644 --- a/object/tree/serialize_test.go +++ b/object/tree/serialize_test.go @@ -60,9 +60,9 @@ func TestTreeSerialize(t *testing.T) { wantTreeID := testRepo.Mktree(t, buildGitMktreeInput(obj.Entries)) - rawObj, err := obj.SerializeWithHeader() + rawObj, err := obj.BytesWithHeader() if err != nil { - t.Fatalf("SerializeWithHeader: %v", err) + t.Fatalf("BytesWithHeader: %v", err) } gotTreeID := algo.Sum(rawObj) diff --git a/reachability/unit_test.go b/reachability/unit_test.go index 1f761108..5be7f6fb 100644 --- a/reachability/unit_test.go +++ b/reachability/unit_test.go @@ -415,9 +415,9 @@ func TestWalkInvalidDomainReturnsPlainError(t *testing.T) { func mustSerializeTree(tb testing.TB, tree *tree.Tree) []byte { tb.Helper() - body, err := tree.SerializeWithoutHeader() + body, err := tree.BytesWithoutHeader() if err != nil { - tb.Fatalf("SerializeWithoutHeader: %v", err) + tb.Fatalf("BytesWithoutHeader: %v", err) } return body -- cgit v1.3.1-10-gc9f91