aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-05-24 08:04:05 +0000
committerGravatar Runxi Yu2026-05-24 08:04:47 +0000
commit279a977c56dba8cdb1c6bf797d8fdcf28a618b44 (patch)
treed99fbaa87a9376605cc35abce39ad533551ed8ba
parentinternal/testgit: Add doc (diff)
signatureNo signature
object/{blob,commit}: Remove testgit and other unsatisfied dependencies for now
This should be reverted (literally, or in effect) sometime.
-rw-r--r--object/blob/append_test.go30
-rw-r--r--object/blob/parse_test.go30
-rw-r--r--object/commit/append_test.go34
-rw-r--r--object/commit/parse_test.go91
-rw-r--r--object/parse.go8
5 files changed, 4 insertions, 189 deletions
diff --git a/object/blob/append_test.go b/object/blob/append_test.go
deleted file mode 100644
index 51f92c48..00000000
--- a/object/blob/append_test.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package blob_test
-
-import (
- "testing"
-
- "codeberg.org/lindenii/furgit/internal/testgit"
- "codeberg.org/lindenii/furgit/object/blob"
- objectid "codeberg.org/lindenii/furgit/object/id"
-)
-
-func TestBlobAppend(t *testing.T) {
- t.Parallel()
- testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper
- testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true})
- body := []byte("hello\nblob\n")
- wantID := testRepo.HashObject(t, "blob", body)
-
- obj := &blob.Blob{Data: body}
-
- rawObj, err := obj.AppendWithHeader([]byte(nil))
- if err != nil {
- t.Fatalf("BytesWithHeader: %v", err)
- }
-
- gotID := algo.Sum(rawObj)
- if gotID != wantID {
- t.Fatalf("object id mismatch: got %s want %s", gotID, wantID)
- }
- })
-}
diff --git a/object/blob/parse_test.go b/object/blob/parse_test.go
deleted file mode 100644
index 09d5d5d0..00000000
--- a/object/blob/parse_test.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package blob_test
-
-import (
- "bytes"
- "testing"
-
- "codeberg.org/lindenii/furgit/internal/testgit"
- "codeberg.org/lindenii/furgit/object/blob"
- objectid "codeberg.org/lindenii/furgit/object/id"
-)
-
-func TestBlobParseFromGit(t *testing.T) {
- t.Parallel()
- testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper
- testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true})
- body := []byte("hello\nblob\n")
- blobID := testRepo.HashObject(t, "blob", body)
-
- rawBody := testRepo.CatFile(t, "blob", blobID)
-
- parsed, err := blob.Parse(rawBody)
- if err != nil {
- t.Fatalf("ParseBlob: %v", err)
- }
-
- if !bytes.Equal(parsed.Data, body) {
- t.Fatalf("blob body mismatch")
- }
- })
-}
diff --git a/object/commit/append_test.go b/object/commit/append_test.go
deleted file mode 100644
index 46b53c69..00000000
--- a/object/commit/append_test.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package commit_test
-
-import (
- "testing"
-
- "codeberg.org/lindenii/furgit/internal/testgit"
- "codeberg.org/lindenii/furgit/object/commit"
- "codeberg.org/lindenii/furgit/object/id"
-)
-
-func TestCommitSerialize(t *testing.T) {
- t.Parallel()
- testgit.ForEachAlgorithm(t, func(t *testing.T, algo id.Algorithm) { //nolint:thelper
- testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true})
- _, _, commitID := testRepo.MakeCommit(t, "subject\n\nbody")
-
- rawBody := testRepo.CatFile(t, "commit", commitID)
-
- parsed, err := commit.Parse(rawBody, algo)
- if err != nil {
- t.Fatalf("ParseCommit: %v", err)
- }
-
- rawObj, err := parsed.AppendWithHeader([]byte(nil))
- if err != nil {
- t.Fatalf("BytesWithHeader: %v", err)
- }
-
- gotID := algo.Sum(rawObj)
- if gotID != commitID {
- t.Fatalf("commit id mismatch: got %s want %s", gotID, commitID)
- }
- })
-}
diff --git a/object/commit/parse_test.go b/object/commit/parse_test.go
deleted file mode 100644
index ad2c7aed..00000000
--- a/object/commit/parse_test.go
+++ /dev/null
@@ -1,91 +0,0 @@
-package commit_test
-
-import (
- "bytes"
- "fmt"
- "testing"
-
- "codeberg.org/lindenii/furgit/internal/testgit"
- "codeberg.org/lindenii/furgit/object/commit"
- objectid "codeberg.org/lindenii/furgit/object/id"
-)
-
-func TestCommitParseFromGit(t *testing.T) {
- t.Parallel()
- testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper
- testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true})
- _, treeID, commitID := testRepo.MakeCommit(t, "subject\n\nbody")
-
- rawBody := testRepo.CatFile(t, "commit", commitID)
-
- parsed, err := commit.Parse(rawBody, algo)
- if err != nil {
- t.Fatalf("ParseCommit: %v", err)
- }
-
- if parsed.Tree != treeID {
- t.Fatalf("tree id mismatch: got %s want %s", parsed.Tree, treeID)
- }
-
- if len(parsed.Parents) != 0 {
- t.Fatalf("parent count = %d, want 0", len(parsed.Parents))
- }
-
- if !bytes.Equal(parsed.Author.Name, []byte("Test Author")) {
- t.Fatalf("author name = %q, want %q", parsed.Author.Name, "Test Author")
- }
-
- if !bytes.Equal(parsed.Committer.Name, []byte("Test Committer")) {
- t.Fatalf("committer name = %q, want %q", parsed.Committer.Name, "Test Committer")
- }
-
- if !bytes.Contains(parsed.Message, []byte("subject")) {
- t.Fatalf("commit message missing subject: %q", parsed.Message)
- }
- })
-}
-
-func TestCommitParseMultipleParents(t *testing.T) {
- t.Parallel()
- testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper
- testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true})
-
- _, treeID := testRepo.MakeSingleFileTree(t, "file.txt", []byte("merge-content\n"))
- parent1 := testRepo.CommitTree(t, treeID, "parent-one")
- parent2 := testRepo.CommitTree(t, treeID, "parent-two", parent1)
-
- rawCommit := fmt.Sprintf(
- "tree %s\nparent %s\nparent %s\nauthor Test Author <test@example.org> 1234567890 +0000\ncommitter Test Committer <committer@example.org> 1234567890 +0000\n\nMerge commit\n",
- treeID,
- parent1,
- parent2,
- )
- mergeID := testRepo.HashObject(t, "commit", []byte(rawCommit))
- rawBody := testRepo.CatFile(t, "commit", mergeID)
-
- parsed, err := commit.Parse(rawBody, algo)
- if err != nil {
- t.Fatalf("ParseCommit(merge): %v", err)
- }
-
- if parsed.Tree != treeID {
- t.Fatalf("merge tree = %s, want %s", parsed.Tree, treeID)
- }
-
- if len(parsed.Parents) != 2 {
- t.Fatalf("merge parent count = %d, want 2", len(parsed.Parents))
- }
-
- if parsed.Parents[0] != parent1 {
- t.Fatalf("merge parent[0] = %s, want %s", parsed.Parents[0], parent1)
- }
-
- if parsed.Parents[1] != parent2 {
- t.Fatalf("merge parent[1] = %s, want %s", parsed.Parents[1], parent2)
- }
-
- if !bytes.Equal(parsed.Message, []byte("Merge commit\n")) {
- t.Fatalf("merge message = %q, want %q", parsed.Message, "Merge commit\n")
- }
- })
-}
diff --git a/object/parse.go b/object/parse.go
index e1ebb5f8..3a2b5eaa 100644
--- a/object/parse.go
+++ b/object/parse.go
@@ -7,9 +7,9 @@ import (
"codeberg.org/lindenii/furgit/object/commit"
"codeberg.org/lindenii/furgit/object/header"
"codeberg.org/lindenii/furgit/object/id"
- "codeberg.org/lindenii/furgit/object/tag"
- "codeberg.org/lindenii/furgit/object/tree"
"codeberg.org/lindenii/furgit/object/typ"
+ // "codeberg.org/lindenii/furgit/object/tag"
+ // "codeberg.org/lindenii/furgit/object/tree"
)
// ParseWithHeader parses a loose object in "type size\x00body" format.
@@ -37,11 +37,11 @@ func ParseWithoutHeader(ty typ.Type, body []byte, algo id.Algorithm) (Object, er
case typ.TypeBlob:
return blob.Parse(body)
case typ.TypeTree:
- return tree.Parse(body, algo)
+ panic("TODO")
case typ.TypeCommit:
return commit.Parse(body, algo)
case typ.TypeTag:
- return tag.Parse(body, algo)
+ panic("TODO")
default:
return nil, fmt.Errorf("object: unsupported object type %d", ty)
}