Fast implementation of Git in pure Go codeberg.org/lindenii/furgit
git go
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

*: Use testgit.NewRepo

Runxi Yu 2852f9a2 304559e6

+57 -53
+7 -7
config/config_test.go
··· 27 27 28 28 func TestConfigAgainstGit(t *testing.T) { 29 29 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 30 - testRepo := testgit.NewBareRepo(t, algo) 30 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 31 31 testRepo.Run(t, "config", "core.bare", "true") 32 32 testRepo.Run(t, "config", "core.filemode", "false") 33 33 testRepo.Run(t, "config", "user.name", "Jane Doe") ··· 58 58 59 59 func TestConfigSubsectionAgainstGit(t *testing.T) { 60 60 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 61 - testRepo := testgit.NewBareRepo(t, algo) 61 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 62 62 testRepo.Run(t, "config", "remote.origin.url", "https://example.org/repo.git") 63 63 testRepo.Run(t, "config", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*") 64 64 ··· 81 81 82 82 func TestConfigMultiValueAgainstGit(t *testing.T) { 83 83 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 84 - testRepo := testgit.NewBareRepo(t, algo) 84 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 85 85 testRepo.Run(t, "config", "--add", "remote.origin.fetch", "+refs/heads/main:refs/remotes/origin/main") 86 86 testRepo.Run(t, "config", "--add", "remote.origin.fetch", "+refs/heads/dev:refs/remotes/origin/dev") 87 87 testRepo.Run(t, "config", "--add", "remote.origin.fetch", "+refs/tags/*:refs/tags/*") ··· 114 114 115 115 func TestConfigCaseInsensitiveAgainstGit(t *testing.T) { 116 116 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 117 - testRepo := testgit.NewBareRepo(t, algo) 117 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 118 118 testRepo.Run(t, "config", "Core.Bare", "true") 119 119 testRepo.Run(t, "config", "CORE.FileMode", "false") 120 120 ··· 143 143 144 144 func TestConfigBooleanAgainstGit(t *testing.T) { 145 145 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 146 - testRepo := testgit.NewBareRepo(t, algo) 146 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 147 147 testRepo.Run(t, "config", "test.flag1", "true") 148 148 testRepo.Run(t, "config", "test.flag2", "false") 149 149 testRepo.Run(t, "config", "test.flag3", "yes") ··· 177 177 178 178 func TestConfigComplexValuesAgainstGit(t *testing.T) { 179 179 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 180 - testRepo := testgit.NewBareRepo(t, algo) 180 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 181 181 testRepo.Run(t, "config", "test.spaced", "value with spaces") 182 182 testRepo.Run(t, "config", "test.special", "value=with=equals") 183 183 testRepo.Run(t, "config", "test.path", "/path/to/something") ··· 203 203 204 204 func TestConfigEntriesAgainstGit(t *testing.T) { 205 205 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 206 - testRepo := testgit.NewBareRepo(t, algo) 206 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 207 207 testRepo.Run(t, "config", "core.bare", "true") 208 208 testRepo.Run(t, "config", "core.filemode", "false") 209 209 testRepo.Run(t, "config", "user.name", "Test User")
+1 -1
object/blob_parse_test.go
··· 11 11 12 12 func TestBlobParseFromGit(t *testing.T) { 13 13 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 14 - testRepo := testgit.NewBareRepo(t, algo) 14 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 15 15 body := []byte("hello\nblob\n") 16 16 blobID := testRepo.HashObject(t, "blob", body) 17 17
+1 -1
object/blob_serialize_test.go
··· 10 10 11 11 func TestBlobSerialize(t *testing.T) { 12 12 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 13 - testRepo := testgit.NewBareRepo(t, algo) 13 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 14 14 body := []byte("hello\nblob\n") 15 15 wantID := testRepo.HashObject(t, "blob", body) 16 16
+1 -1
object/commit_parse_test.go
··· 11 11 12 12 func TestCommitParseFromGit(t *testing.T) { 13 13 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 14 - testRepo := testgit.NewBareRepo(t, algo) 14 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 15 15 _, treeID, commitID := testRepo.MakeCommit(t, "subject\n\nbody") 16 16 17 17 rawBody := testRepo.CatFile(t, "commit", commitID)
+1 -1
object/commit_serialize_test.go
··· 10 10 11 11 func TestCommitSerialize(t *testing.T) { 12 12 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 13 - testRepo := testgit.NewBareRepo(t, algo) 13 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 14 14 _, _, commitID := testRepo.MakeCommit(t, "subject\n\nbody") 15 15 16 16 rawBody := testRepo.CatFile(t, "commit", commitID)
+1 -1
object/tag_parse_test.go
··· 12 12 13 13 func TestTagParseFromGit(t *testing.T) { 14 14 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 15 - testRepo := testgit.NewBareRepo(t, algo) 15 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 16 16 _, _, commitID := testRepo.MakeCommit(t, "subject\n\nbody") 17 17 tagID := testRepo.TagAnnotated(t, "v1", commitID, "tag message") 18 18
+1 -1
object/tag_serialize_test.go
··· 10 10 11 11 func TestTagSerialize(t *testing.T) { 12 12 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 13 - testRepo := testgit.NewBareRepo(t, algo) 13 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 14 14 _, _, commitID := testRepo.MakeCommit(t, "subject\n\nbody") 15 15 tagID := testRepo.TagAnnotated(t, "v1", commitID, "tag message") 16 16
+1 -1
object/tree_parse_test.go
··· 11 11 12 12 func TestTreeParseFromGit(t *testing.T) { 13 13 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 14 - testRepo := testgit.NewBareRepo(t, algo) 14 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 15 15 entries := adversarialRootEntries(t, testRepo) 16 16 inserted := &object.Tree{} 17 17 for _, entry := range entries {
+1 -1
object/tree_serialize_test.go
··· 10 10 11 11 func TestTreeSerialize(t *testing.T) { 12 12 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 13 - testRepo := testgit.NewBareRepo(t, algo) 13 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 14 14 entries := adversarialRootEntries(t, testRepo) 15 15 tree := &object.Tree{} 16 16
+2 -2
objectstore/loose/read_test.go
··· 15 15 16 16 func TestLooseStoreReadAgainstGit(t *testing.T) { 17 17 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 18 - testRepo := testgit.NewBareRepo(t, algo) 18 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 19 19 blobID := testRepo.HashObject(t, "blob", []byte("blob body\n")) 20 20 _, treeID, commitID := testRepo.MakeCommit(t, "subject\n\nbody") 21 21 tagID := testRepo.TagAnnotated(t, "v1", commitID, "tag message") ··· 94 94 95 95 func TestLooseStoreErrors(t *testing.T) { 96 96 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 97 - testRepo := testgit.NewBareRepo(t, algo) 97 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 98 98 store := openLooseStore(t, testRepo.Dir(), algo) 99 99 100 100 notFoundID, err := objectid.ParseHex(algo, strings.Repeat("0", algo.HexLen()))
+26 -26
objectstore/loose/write_test.go
··· 13 13 14 14 func TestLooseStoreWriteWriterContentAgainstGit(t *testing.T) { 15 15 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 16 - testRepo := testgit.NewBareRepo(t, algo) 16 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 17 17 store := openLooseStore(t, testRepo.Dir(), algo) 18 18 19 19 content := []byte("written-by-content-writer\n") ··· 41 41 t.Fatalf("WriteWriterContent id = %s, want %s", writtenID, expectedID) 42 42 } 43 43 44 - gotBody := testRepo.CatFile(t, "blob", writtenID) 45 - if !bytes.Equal(gotBody, content) { 46 - t.Fatalf("git cat-file body mismatch") 47 - } 44 + gotBody := testRepo.CatFile(t, "blob", writtenID) 45 + if !bytes.Equal(gotBody, content) { 46 + t.Fatalf("git cat-file body mismatch") 47 + } 48 48 49 - // Writing the same object again should succeed and return the same ID. 50 - writer, finalize, err = store.WriteWriterContent(objecttype.TypeBlob, int64(len(content))) 51 - if err != nil { 52 - t.Fatalf("WriteWriterContent second: %v", err) 53 - } 54 - if _, err := io.Copy(writer, bytes.NewReader(content)); err != nil { 55 - t.Fatalf("WriteWriterContent second write: %v", err) 56 - } 57 - if err := writer.Close(); err != nil { 58 - t.Fatalf("WriteWriterContent second close: %v", err) 59 - } 60 - writtenID2, err := finalize() 61 - if err != nil { 62 - t.Fatalf("WriteWriterContent second finalize: %v", err) 63 - } 64 - if writtenID2 != expectedID { 65 - t.Fatalf("WriteWriterContent second id = %s, want %s", writtenID2, expectedID) 66 - } 67 - }) 49 + // Writing the same object again should succeed and return the same ID. 50 + writer, finalize, err = store.WriteWriterContent(objecttype.TypeBlob, int64(len(content))) 51 + if err != nil { 52 + t.Fatalf("WriteWriterContent second: %v", err) 53 + } 54 + if _, err := io.Copy(writer, bytes.NewReader(content)); err != nil { 55 + t.Fatalf("WriteWriterContent second write: %v", err) 56 + } 57 + if err := writer.Close(); err != nil { 58 + t.Fatalf("WriteWriterContent second close: %v", err) 59 + } 60 + writtenID2, err := finalize() 61 + if err != nil { 62 + t.Fatalf("WriteWriterContent second finalize: %v", err) 63 + } 64 + if writtenID2 != expectedID { 65 + t.Fatalf("WriteWriterContent second id = %s, want %s", writtenID2, expectedID) 66 + } 67 + }) 68 68 } 69 69 70 70 func TestLooseStoreWriteWriterFullAgainstGit(t *testing.T) { 71 71 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 72 - testRepo := testgit.NewBareRepo(t, algo) 72 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 73 73 store := openLooseStore(t, testRepo.Dir(), algo) 74 74 75 75 body := []byte("full-writer-body\n") ··· 109 109 110 110 func TestLooseStoreWriterValidationErrors(t *testing.T) { 111 111 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 112 - testRepo := testgit.NewBareRepo(t, algo) 112 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 113 113 store := openLooseStore(t, testRepo.Dir(), algo) 114 114 115 115 t.Run("content overflow", func(t *testing.T) {
+1 -1
objectstore/packed/helpers_test.go
··· 68 68 func createPackedFixtureRepo(t *testing.T, algo objectid.Algorithm) (*testgit.TestRepo, []objectid.ObjectID) { 69 69 t.Helper() 70 70 71 - testRepo := testgit.NewBareRepo(t, algo) 71 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 72 72 blobID, treeID, commitID := testRepo.MakeCommit(t, "packed store base commit") 73 73 testRepo.Run(t, "update-ref", "refs/heads/main", commitID.String()) 74 74 tagID := testRepo.TagAnnotated(t, "v1.0.0", commitID, "packed-store-tag")
+1 -1
objectstore/packed/read_test.go
··· 136 136 } 137 137 138 138 func TestPackedStoreInvalidAlgorithm(t *testing.T) { 139 - testRepo := testgit.NewBareRepo(t, objectid.AlgorithmSHA1) 139 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: objectid.AlgorithmSHA1, Bare: true}) 140 140 root, err := os.OpenRoot(testRepo.Dir()) 141 141 if err != nil { 142 142 t.Fatalf("OpenRoot(%q): %v", testRepo.Dir(), err)
+5 -5
refstore/loose/loose_test.go
··· 31 31 32 32 func TestLooseResolveAndResolveFully(t *testing.T) { 33 33 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 34 - testRepo := testgit.NewBareRepo(t, algo) 34 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 35 35 _, _, commitID := testRepo.MakeCommit(t, "loose refs commit") 36 36 testRepo.UpdateRef(t, "refs/heads/main", commitID) 37 37 testRepo.SymbolicRef(t, "HEAD", "refs/heads/main") ··· 78 78 79 79 func TestLooseResolveFullyCycle(t *testing.T) { 80 80 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 81 - testRepo := testgit.NewBareRepo(t, algo) 81 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 82 82 testRepo.SymbolicRef(t, "refs/heads/a", "refs/heads/b") 83 83 testRepo.SymbolicRef(t, "refs/heads/b", "refs/heads/a") 84 84 ··· 91 91 92 92 func TestLooseListPattern(t *testing.T) { 93 93 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 94 - testRepo := testgit.NewBareRepo(t, algo) 94 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 95 95 _, _, commitID := testRepo.MakeCommit(t, "list refs commit") 96 96 testRepo.UpdateRef(t, "refs/heads/main", commitID) 97 97 testRepo.UpdateRef(t, "refs/heads/feature", commitID) ··· 132 132 133 133 func TestLooseMalformedDetachedRef(t *testing.T) { 134 134 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 135 - testRepo := testgit.NewBareRepo(t, algo) 135 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 136 136 refPath := filepath.Join(testRepo.Dir(), "refs", "heads", "bad") 137 137 if err := os.MkdirAll(filepath.Dir(refPath), 0o755); err != nil { 138 138 t.Fatalf("MkdirAll: %v", err) ··· 150 150 151 151 func TestLooseShorten(t *testing.T) { 152 152 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 153 - testRepo := testgit.NewBareRepo(t, algo) 153 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 154 154 _, _, commitID := testRepo.MakeCommit(t, "shorten refs commit") 155 155 testRepo.UpdateRef(t, "refs/heads/main", commitID) 156 156 testRepo.UpdateRef(t, "refs/tags/main", commitID)
+2 -2
refstore/packed/packed_test.go
··· 32 32 33 33 func TestPackedResolveAndPeeled(t *testing.T) { 34 34 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 35 - testRepo := testgit.NewBareRepo(t, algo) 35 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 36 36 _, _, commitID := testRepo.MakeCommit(t, "packed refs commit") 37 37 testRepo.UpdateRef(t, "refs/heads/main", commitID) 38 38 tagID := testRepo.TagAnnotated(t, "v1.0.0", commitID, "annotated tag") ··· 86 86 87 87 func TestPackedListAndShorten(t *testing.T) { 88 88 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { 89 - testRepo := testgit.NewBareRepo(t, algo) 89 + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 90 90 _, _, commitID := testRepo.MakeCommit(t, "packed refs list commit") 91 91 testRepo.UpdateRef(t, "refs/heads/main", commitID) 92 92 testRepo.UpdateRef(t, "refs/tags/main", commitID)
+5 -1
refstore/reftable/reftable_test.go
··· 17 17 // newBareReftableRepo creates a bare repository that uses reftable ref storage. 18 18 func newBareReftableRepo(tb testing.TB, algo objectid.Algorithm) *testgit.TestRepo { 19 19 tb.Helper() 20 - return testgit.NewRepo(tb, algo, testgit.RepoOptions{Bare: true, RefFormat: "reftable"}) 20 + return testgit.NewRepo(tb, testgit.RepoOptions{ 21 + ObjectFormat: algo, 22 + Bare: true, 23 + RefFormat: "reftable", 24 + }) 21 25 } 22 26 23 27 // openStore opens a reftable store against repoDir/reftable.