Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-03-05 15:24:04 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-03-09 14:30:33 +0300
commit9566ac120abe7565d4a1736bf6027daa202c136f (patch)
tree2e94cdc1d64943ddd6bb43a529d80fb08b9481b6 /internal/git2go
parentce75db738ce163efc3e9d118c1a6f2393394cb8c (diff)
localrepo: Use ObjectIDs when reading/writing git objects
Both the `ReadObject()` and `WriteBlob()` functions currently accept, respectively return, an untyped string. Convert these functions to use an ObjectID to better convey its meaning.
Diffstat (limited to 'internal/git2go')
-rw-r--r--internal/git2go/apply_test.go12
-rw-r--r--internal/git2go/commit_test.go52
2 files changed, 32 insertions, 32 deletions
diff --git a/internal/git2go/apply_test.go b/internal/git2go/apply_test.go
index e3ed37d8c..6f303257c 100644
--- a/internal/git2go/apply_test.go
+++ b/internal/git2go/apply_test.go
@@ -42,7 +42,7 @@ func TestExecutor_Apply(t *testing.T) {
Author: author,
Committer: committer,
Message: "base commit",
- Actions: []Action{CreateFile{Path: "file", OID: oidBase}},
+ Actions: []Action{CreateFile{Path: "file", OID: oidBase.String()}},
})
require.NoError(t, err)
@@ -51,7 +51,7 @@ func TestExecutor_Apply(t *testing.T) {
Author: author,
Committer: committer,
Message: "commit with ab",
- Actions: []Action{CreateFile{Path: "file", OID: oidA}},
+ Actions: []Action{CreateFile{Path: "file", OID: oidA.String()}},
})
require.NoError(t, err)
@@ -61,7 +61,7 @@ func TestExecutor_Apply(t *testing.T) {
Committer: committer,
Message: "commit with a",
Parent: parentCommitSHA,
- Actions: []Action{UpdateFile{Path: "file", OID: oidA}},
+ Actions: []Action{UpdateFile{Path: "file", OID: oidA.String()}},
})
require.NoError(t, err)
@@ -71,7 +71,7 @@ func TestExecutor_Apply(t *testing.T) {
Committer: committer,
Message: "commit to b",
Parent: parentCommitSHA,
- Actions: []Action{UpdateFile{Path: "file", OID: oidB}},
+ Actions: []Action{UpdateFile{Path: "file", OID: oidB.String()}},
})
require.NoError(t, err)
@@ -81,7 +81,7 @@ func TestExecutor_Apply(t *testing.T) {
Committer: committer,
Message: "commit a -> b",
Parent: updateToA,
- Actions: []Action{UpdateFile{Path: "file", OID: oidB}},
+ Actions: []Action{UpdateFile{Path: "file", OID: oidB.String()}},
})
require.NoError(t, err)
@@ -90,7 +90,7 @@ func TestExecutor_Apply(t *testing.T) {
Author: author,
Committer: committer,
Message: "commit with other-file",
- Actions: []Action{CreateFile{Path: "other-file", OID: oidA}},
+ Actions: []Action{CreateFile{Path: "other-file", OID: oidA.String()}},
})
require.NoError(t, err)
diff --git a/internal/git2go/commit_test.go b/internal/git2go/commit_test.go
index 6e689a314..c4c8427f7 100644
--- a/internal/git2go/commit_test.go
+++ b/internal/git2go/commit_test.go
@@ -120,7 +120,7 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "file", OID: originalFile},
+ CreateFile{Path: "file", OID: originalFile.String()},
},
treeEntries: []gittest.TreeEntry{
{Mode: DefaultMode, Path: "file", Content: "original"},
@@ -139,7 +139,7 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "file", OID: originalFile},
+ CreateFile{Path: "file", OID: originalFile.String()},
},
treeEntries: []gittest.TreeEntry{
{Mode: DefaultMode, Path: "file", Content: "original"},
@@ -152,8 +152,8 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "file", OID: originalFile},
- CreateFile{Path: "file", OID: updatedFile},
+ CreateFile{Path: "file", OID: originalFile.String()},
+ CreateFile{Path: "file", OID: updatedFile.String()},
},
error: FileExistsError("file"),
},
@@ -165,7 +165,7 @@ func TestExecutor_Commit(t *testing.T) {
{
actions: []Action{
CreateDirectory{Path: "directory"},
- CreateFile{Path: "directory", OID: originalFile},
+ CreateFile{Path: "directory", OID: originalFile.String()},
},
treeEntries: []gittest.TreeEntry{
{Mode: DefaultMode, Path: "directory", Content: "original"},
@@ -178,8 +178,8 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "file", OID: originalFile},
- UpdateFile{Path: "file", OID: updatedFile},
+ CreateFile{Path: "file", OID: originalFile.String()},
+ UpdateFile{Path: "file", OID: updatedFile.String()},
},
treeEntries: []gittest.TreeEntry{
{Mode: DefaultMode, Path: "file", Content: "updated"},
@@ -192,7 +192,7 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "file", OID: originalFile},
+ CreateFile{Path: "file", OID: originalFile.String()},
},
treeEntries: []gittest.TreeEntry{
{Mode: DefaultMode, Path: "file", Content: "original"},
@@ -200,7 +200,7 @@ func TestExecutor_Commit(t *testing.T) {
},
{
actions: []Action{
- UpdateFile{Path: "file", OID: updatedFile},
+ UpdateFile{Path: "file", OID: updatedFile.String()},
},
treeEntries: []gittest.TreeEntry{
{Mode: DefaultMode, Path: "file", Content: "updated"},
@@ -213,7 +213,7 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- UpdateFile{Path: "non-existing", OID: updatedFile},
+ UpdateFile{Path: "non-existing", OID: updatedFile.String()},
},
error: FileNotFoundError("non-existing"),
},
@@ -224,8 +224,8 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "original-file", OID: originalFile},
- MoveFile{Path: "original-file", NewPath: "moved-file", OID: originalFile},
+ CreateFile{Path: "original-file", OID: originalFile.String()},
+ MoveFile{Path: "original-file", NewPath: "moved-file", OID: originalFile.String()},
},
treeEntries: []gittest.TreeEntry{
{Mode: DefaultMode, Path: "moved-file", Content: "original"},
@@ -250,7 +250,7 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "original-file", OID: originalFile},
+ CreateFile{Path: "original-file", OID: originalFile.String()},
},
treeEntries: []gittest.TreeEntry{
{Mode: DefaultMode, Path: "original-file", Content: "original"},
@@ -282,8 +282,8 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "source-file", OID: originalFile},
- CreateFile{Path: "already-existing", OID: updatedFile},
+ CreateFile{Path: "source-file", OID: originalFile.String()},
+ CreateFile{Path: "already-existing", OID: updatedFile.String()},
MoveFile{Path: "source-file", NewPath: "already-existing"},
},
error: FileExistsError("already-existing"),
@@ -297,7 +297,7 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "file", OID: originalFile},
+ CreateFile{Path: "file", OID: originalFile.String()},
CreateDirectory{Path: "already-existing"},
MoveFile{Path: "file", NewPath: "already-existing"},
},
@@ -312,7 +312,7 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "original-file", OID: originalFile},
+ CreateFile{Path: "original-file", OID: originalFile.String()},
},
treeEntries: []gittest.TreeEntry{
{Mode: DefaultMode, Path: "original-file", Content: "original"},
@@ -320,7 +320,7 @@ func TestExecutor_Commit(t *testing.T) {
},
{
actions: []Action{
- MoveFile{Path: "original-file", NewPath: "moved-file", OID: updatedFile},
+ MoveFile{Path: "original-file", NewPath: "moved-file", OID: updatedFile.String()},
},
treeEntries: []gittest.TreeEntry{
{Mode: DefaultMode, Path: "moved-file", Content: "updated"},
@@ -344,7 +344,7 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "file-1", OID: originalFile},
+ CreateFile{Path: "file-1", OID: originalFile.String()},
ChangeFileMode{Path: "file-1", ExecutableMode: true},
},
treeEntries: []gittest.TreeEntry{
@@ -366,7 +366,7 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "file-1", OID: originalFile},
+ CreateFile{Path: "file-1", OID: originalFile.String()},
ChangeFileMode{Path: "file-1", ExecutableMode: true},
},
treeEntries: []gittest.TreeEntry{
@@ -380,7 +380,7 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "file-1", OID: originalFile},
+ CreateFile{Path: "file-1", OID: originalFile.String()},
},
treeEntries: []gittest.TreeEntry{
{Mode: DefaultMode, Path: "file-1", Content: "original"},
@@ -412,8 +412,8 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "file-1", OID: originalFile},
- CreateFile{Path: "file-2", OID: updatedFile},
+ CreateFile{Path: "file-1", OID: originalFile.String()},
+ CreateFile{Path: "file-2", OID: updatedFile.String()},
MoveFile{Path: "file-1", NewPath: "file-2"},
},
error: FileExistsError("file-2"),
@@ -436,7 +436,7 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "file-1", OID: originalFile},
+ CreateFile{Path: "file-1", OID: originalFile.String()},
DeleteFile{Path: "file-1"},
},
},
@@ -447,7 +447,7 @@ func TestExecutor_Commit(t *testing.T) {
steps: []step{
{
actions: []Action{
- CreateFile{Path: "file-1", OID: originalFile},
+ CreateFile{Path: "file-1", OID: originalFile.String()},
},
treeEntries: []gittest.TreeEntry{
{Mode: DefaultMode, Path: "file-1", Content: "original"},
@@ -500,7 +500,7 @@ func TestExecutor_Commit(t *testing.T) {
func getCommit(t testing.TB, ctx context.Context, repo *localrepo.Repo, oid string) commit {
t.Helper()
- data, err := repo.ReadObject(ctx, oid)
+ data, err := repo.ReadObject(ctx, git.ObjectID(oid))
require.NoError(t, err)
var commit commit