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>2021-08-31 01:51:55 +0300
committerJames Fargher <jfargher@gitlab.com>2021-09-13 02:28:19 +0300
commit501eb8b5ca5eefe536acc2d6fd9013fd3e64ede1 (patch)
tree6001feabeb4b99c2cc1da5b48278ad991b098e5c
parent022006d71c3c6eba4ddc25fe3a021c9e4fa4a7c9 (diff)
Refactor remote service to use GetDefaultBranch
-rw-r--r--internal/gitaly/service/remote/fetch_internal_remote.go4
-rw-r--r--internal/gitaly/service/remote/update_remote_mirror.go5
2 files changed, 4 insertions, 5 deletions
diff --git a/internal/gitaly/service/remote/fetch_internal_remote.go b/internal/gitaly/service/remote/fetch_internal_remote.go
index 7eafcf23b..b43dde15e 100644
--- a/internal/gitaly/service/remote/fetch_internal_remote.go
+++ b/internal/gitaly/service/remote/fetch_internal_remote.go
@@ -61,12 +61,12 @@ func FetchInternalRemote(
return status.Errorf(codes.Internal, "FetchInternalRemote: remote default branch: %v", err)
}
- defaultBranch, err := ref.DefaultBranchName(ctx, repo)
+ defaultBranch, err := repo.GetDefaultBranch(ctx, nil)
if err != nil {
return status.Errorf(codes.Internal, "FetchInternalRemote: default branch: %v", err)
}
- if !bytes.Equal(defaultBranch, remoteDefaultBranch) {
+ if defaultBranch.Name.String() != string(remoteDefaultBranch) {
if err := ref.SetDefaultBranchRef(ctx, repo, string(remoteDefaultBranch), cfg); err != nil {
return status.Errorf(codes.Internal, "FetchInternalRemote: set default branch: %v", err)
}
diff --git a/internal/gitaly/service/remote/update_remote_mirror.go b/internal/gitaly/service/remote/update_remote_mirror.go
index 8ab8f4ac9..69d0628d0 100644
--- a/internal/gitaly/service/remote/update_remote_mirror.go
+++ b/internal/gitaly/service/remote/update_remote_mirror.go
@@ -10,7 +10,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/git"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service/ref"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
@@ -103,7 +102,7 @@ func (s *server) updateRemoteMirror(stream gitalypb.RemoteService_UpdateRemoteMi
return fmt.Errorf("get local references: %w", err)
}
- defaultBranch, err := ref.DefaultBranchName(ctx, repo)
+ defaultBranch, err := repo.GetDefaultBranch(ctx, nil)
if err != nil {
return fmt.Errorf("get default branch: %w", err)
}
@@ -195,7 +194,7 @@ func (s *server) updateRemoteMirror(stream gitalypb.RemoteService_UpdateRemoteMi
}
refspecs = append(refspecs, prefix+reference.String())
- if reference == git.ReferenceName(defaultBranch) {
+ if reference == defaultBranch.Name {
// The default branch needs to be pushed in the first batch of refspecs as some features
// depend on it existing in the repository. The default branch may not exist in the repo
// yet if this is the first mirroring push.