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>2020-10-14 13:15:35 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-10-14 13:15:35 +0300
commit9866ebbbb431fd0e767514a345ce2bd0015c8c4b (patch)
treece6d813543fb94890edfb9608cc0fbed7b33fc98
parent0e7ea33c08fae22bb9db43e353acf2e95bf4115d (diff)
git: Rename CatFile to ReadObject
The repository interface has recently grown a new function `CatFile`, which uses git-cat-file(1) to read a Git object from the ODB and returns its contents. The name is quite implementation-specific though and thus may be hard to discover for people not familiar with the low-level plumbing commands. Furthermore, other interfaces like e.g. the RemoteRepository interface may not use git-cat-file at all to implement it. Rename the function to `ReadObject` to make it easier to discover and less implementation-specific.
-rw-r--r--internal/git/repository.go6
-rw-r--r--internal/git/repository_test.go6
2 files changed, 6 insertions, 6 deletions
diff --git a/internal/git/repository.go b/internal/git/repository.go
index ab0dce686..c4a71c752 100644
--- a/internal/git/repository.go
+++ b/internal/git/repository.go
@@ -69,9 +69,9 @@ type Repository interface {
// run on the content.
WriteBlob(ctx context.Context, path string, content io.Reader) (string, error)
- // CatFile reads an object from the repository's object database. InvalidObjectError
+ // ReadObject reads an object from the repository's object database. InvalidObjectError
// is returned if the oid does not refer to a valid object.
- CatFile(ctx context.Context, oid string) ([]byte, error)
+ ReadObject(ctx context.Context, oid string) ([]byte, error)
}
// localRepository represents a local Git repository.
@@ -120,7 +120,7 @@ func (repo *localRepository) WriteBlob(ctx context.Context, path string, content
return text.ChompBytes(stdout.Bytes()), nil
}
-func (repo *localRepository) CatFile(ctx context.Context, oid string) ([]byte, error) {
+func (repo *localRepository) ReadObject(ctx context.Context, oid string) ([]byte, error) {
const msgInvalidObject = "fatal: Not a valid object name "
stdout := &bytes.Buffer{}
diff --git a/internal/git/repository_test.go b/internal/git/repository_test.go
index 3b6a2e3e0..685da5a92 100644
--- a/internal/git/repository_test.go
+++ b/internal/git/repository_test.go
@@ -325,14 +325,14 @@ lf text
}
assert.Equal(t, tc.sha, sha)
- content, err := repo.CatFile(ctx, sha)
+ content, err := repo.ReadObject(ctx, sha)
require.NoError(t, err)
assert.Equal(t, tc.content, string(content))
})
}
}
-func TestLocalRepository_CatFile(t *testing.T) {
+func TestLocalRepository_ReadObject(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
@@ -357,7 +357,7 @@ func TestLocalRepository_CatFile(t *testing.T) {
},
} {
t.Run(tc.desc, func(t *testing.T) {
- content, err := repo.CatFile(ctx, tc.oid)
+ content, err := repo.ReadObject(ctx, tc.oid)
require.Equal(t, tc.error, err)
require.Equal(t, tc.content, string(content))
})