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:
authorJames Fargher <jfargher@gitlab.com>2023-04-18 01:58:51 +0300
committerJames Fargher <jfargher@gitlab.com>2023-04-18 01:58:51 +0300
commit644abe1e5baebabbf4a5142be62ec4c90e3bfa8f (patch)
tree0d6f7d9c5889b19a324cc8e465946c6fa699b01f
parent445c2db73af949f4f7145ffdd4d444ee8b0ab45b (diff)
backup: Change ListRefs to GetReferencesbackup_localrepo
Changing ListRefs to GetReferences to better match localrepo.Repo.
-rw-r--r--internal/backup/backup.go15
-rw-r--r--internal/backup/repository.go10
2 files changed, 14 insertions, 11 deletions
diff --git a/internal/backup/backup.go b/internal/backup/backup.go
index 7d1c0506c..6ea3808f5 100644
--- a/internal/backup/backup.go
+++ b/internal/backup/backup.go
@@ -9,6 +9,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/client"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/v15/streamio"
@@ -24,9 +25,6 @@ var (
ErrDoesntExist = errors.New("doesn't exist")
)
-// errEmptyBundle means that the requested bundle contained nothing
-var errEmptyBundle = errors.New("empty bundle")
-
// Sink is an abstraction over the real storage used for storing/restoring backups.
type Sink interface {
// GetWriter saves the written data to relativePath. It is the callers
@@ -83,8 +81,9 @@ type Repository interface {
GetReferences(ctx context.Context, patterns ...string) ([]git.Reference, error)
// GetCustomHooks fetches the custom hooks archive.
GetCustomHooks(ctx context.Context) (io.Reader, error)
- // CreateBundle fetches a bundle that contains refs matching patterns.
- CreateBundle(ctx context.Context, out io.Writer, patterns io.Reader) error
+ // CreateBundle creates a bundle that contains all refs.
+ // When the bundle would be empty localrepo.ErrEmptyBundle is returned.
+ CreateBundle(ctx context.Context, out io.Writer, opts *localrepo.CreateBundleOpts) error
}
// ResolveLocator returns a locator implementation based on a locator identifier.
@@ -360,8 +359,10 @@ func (mgr *Manager) writeBundle(ctx context.Context, repo Repository, step *Step
}
}()
- if err := repo.CreateBundle(ctx, w, io.MultiReader(negatedRefs, patternReader)); err != nil {
- if errors.Is(err, errEmptyBundle) {
+ if err := repo.CreateBundle(ctx, w, &localrepo.CreateBundleOpts{
+ Patterns: io.MultiReader(negatedRefs, patternReader),
+ }); err != nil {
+ if errors.Is(err, localrepo.ErrEmptyBundle) {
return fmt.Errorf("write bundle: %w: no changes to bundle", ErrSkipped)
}
return fmt.Errorf("write bundle: %w", err)
diff --git a/internal/backup/repository.go b/internal/backup/repository.go
index 60ae03448..e559e1cdd 100644
--- a/internal/backup/repository.go
+++ b/internal/backup/repository.go
@@ -9,6 +9,7 @@ import (
"io"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper/chunk"
"gitlab.com/gitlab-org/gitaly/v15/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
@@ -95,8 +96,9 @@ func (rr *remoteRepository) GetCustomHooks(ctx context.Context) (io.Reader, erro
}), nil
}
-// CreateBundle fetches a bundle that contains refs matching patterns.
-func (rr *remoteRepository) CreateBundle(ctx context.Context, out io.Writer, patterns io.Reader) error {
+// CreateBundle creates a bundle that contains all refs.
+// When the bundle would be empty localrepo.ErrEmptyBundle is returned.
+func (rr *remoteRepository) CreateBundle(ctx context.Context, out io.Writer, opts *localrepo.CreateBundleOpts) error {
repoClient := rr.newRepoClient()
stream, err := repoClient.CreateBundleFromRefList(ctx)
if err != nil {
@@ -106,7 +108,7 @@ func (rr *remoteRepository) CreateBundle(ctx context.Context, out io.Writer, pat
stream: stream,
})
- buf := bufio.NewReader(patterns)
+ buf := bufio.NewReader(opts.Patterns)
for {
line, err := buf.ReadBytes('\n')
if errors.Is(err, io.EOF) {
@@ -134,7 +136,7 @@ func (rr *remoteRepository) CreateBundle(ctx context.Context, out io.Writer, pat
bundle := streamio.NewReader(func() ([]byte, error) {
resp, err := stream.Recv()
if structerr.GRPCCode(err) == codes.FailedPrecondition {
- err = errEmptyBundle
+ err = localrepo.ErrEmptyBundle
}
return resp.GetData(), err
})