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:
Diffstat (limited to 'internal/gitaly/service/remote/find_remote_root_ref.go')
-rw-r--r--internal/gitaly/service/remote/find_remote_root_ref.go33
1 files changed, 11 insertions, 22 deletions
diff --git a/internal/gitaly/service/remote/find_remote_root_ref.go b/internal/gitaly/service/remote/find_remote_root_ref.go
index dc4302783..fb2f0adf0 100644
--- a/internal/gitaly/service/remote/find_remote_root_ref.go
+++ b/internal/gitaly/service/remote/find_remote_root_ref.go
@@ -16,28 +16,22 @@ import (
const headPrefix = "HEAD branch: "
func (s *server) findRemoteRootRef(ctx context.Context, request *gitalypb.FindRemoteRootRefRequest) (string, error) {
- remoteName := request.Remote // nolint:staticcheck
- var config []git.ConfigPair
-
- if request.RemoteUrl != "" {
- remoteName = "inmemory"
- config = []git.ConfigPair{
- {Key: "remote.inmemory.url", Value: request.RemoteUrl},
- }
+ config := []git.ConfigPair{
+ {Key: "remote.inmemory.url", Value: request.RemoteUrl},
+ }
- if authHeader := request.GetHttpAuthorizationHeader(); authHeader != "" {
- config = append(config, git.ConfigPair{
- Key: fmt.Sprintf("http.%s.extraHeader", request.RemoteUrl),
- Value: "Authorization: " + authHeader,
- })
- }
+ if authHeader := request.GetHttpAuthorizationHeader(); authHeader != "" {
+ config = append(config, git.ConfigPair{
+ Key: fmt.Sprintf("http.%s.extraHeader", request.RemoteUrl),
+ Value: "Authorization: " + authHeader,
+ })
}
cmd, err := s.gitCmdFactory.New(ctx, request.Repository,
git.SubSubCmd{
Name: "remote",
Action: "show",
- Args: []string{remoteName},
+ Args: []string{"inmemory"},
},
git.WithRefTxHook(ctx, request.Repository, s.cfg),
git.WithConfigEnv(config...),
@@ -72,13 +66,8 @@ func (s *server) findRemoteRootRef(ctx context.Context, request *gitalypb.FindRe
// FindRemoteRootRef queries the remote to determine its HEAD
func (s *server) FindRemoteRootRef(ctx context.Context, in *gitalypb.FindRemoteRootRefRequest) (*gitalypb.FindRemoteRootRefResponse, error) {
- //nolint:staticcheck // GetRemote() is deprecated
- if in.GetRemote() == "" && in.GetRemoteUrl() == "" {
- return nil, status.Error(codes.InvalidArgument, "got neither remote name nor URL")
- }
- //nolint:staticcheck // GetRemote() is deprecated
- if in.GetRemote() != "" && in.GetRemoteUrl() != "" {
- return nil, status.Error(codes.InvalidArgument, "got remote name and URL")
+ if in.GetRemoteUrl() == "" {
+ return nil, status.Error(codes.InvalidArgument, "missing remote URL")
}
if in.Repository == nil {
return nil, status.Error(codes.InvalidArgument, "missing repository")