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:
authorMichael Leopard <mleopard@gitlab.com>2018-12-17 18:37:51 +0300
committerMichael Leopard <mleopard@gitlab.com>2018-12-17 18:37:51 +0300
commit9efc6b02e63fe28864a7799339f6c5b413770acb (patch)
tree1b6b9ee47142ea0e9263c95a3ac6ad6393330b89
parentc4e9f6bc5db73bb3331a088364b2c87489e9eb7c (diff)
Cleaning up awkward type casts. Marking find_branch as deprecated.
-rw-r--r--internal/service/ref/branches.go14
-rw-r--r--ruby/lib/gitaly_server/ref_service.rb15
2 files changed, 22 insertions, 7 deletions
diff --git a/internal/service/ref/branches.go b/internal/service/ref/branches.go
index 8cff6a1bc..83a55652d 100644
--- a/internal/service/ref/branches.go
+++ b/internal/service/ref/branches.go
@@ -2,9 +2,9 @@ package ref
import (
"bufio"
- "bytes"
"fmt"
"io"
+ "strings"
"gitlab.com/gitlab-org/gitaly-proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/internal/git"
@@ -44,16 +44,16 @@ func (s *server) DeleteBranch(ctx context.Context, req *gitalypb.DeleteBranchReq
}
func (s *server) FindBranch(ctx context.Context, req *gitalypb.FindBranchRequest) (*gitalypb.FindBranchResponse, error) {
- refName := req.GetName()
+ refName := string(req.GetName())
if len(refName) == 0 {
return nil, status.Errorf(codes.InvalidArgument, "Branch name cannot be empty")
}
repo := req.GetRepository()
- if bytes.HasPrefix(refName, []byte("refs/heads/")) {
- refName = bytes.TrimPrefix(refName, []byte("refs/heads/"))
- } else if bytes.HasPrefix(refName, []byte("heads/")) {
- refName = bytes.TrimPrefix(refName, []byte("heads/"))
+ if strings.HasPrefix(refName, "refs/heads/") {
+ refName = strings.TrimPrefix(refName, "refs/heads/")
+ } else if strings.HasPrefix(refName, "heads/") {
+ refName = strings.TrimPrefix(refName, "heads/")
}
cmd, err := git.Command(ctx, repo, "for-each-ref", "--format", "%(objectname)", fmt.Sprintf("refs/heads/%s", string(refName)))
@@ -81,7 +81,7 @@ func (s *server) FindBranch(ctx context.Context, req *gitalypb.FindBranchRequest
return &gitalypb.FindBranchResponse{
Branch: &gitalypb.Branch{
- Name: refName,
+ Name: []byte(refName),
TargetCommit: commit,
},
}, nil
diff --git a/ruby/lib/gitaly_server/ref_service.rb b/ruby/lib/gitaly_server/ref_service.rb
index 9cd90d31a..9b3fa036c 100644
--- a/ruby/lib/gitaly_server/ref_service.rb
+++ b/ruby/lib/gitaly_server/ref_service.rb
@@ -44,6 +44,21 @@ module GitalyServer
raise GRPC::Internal.new(e.to_s)
end
+ # Deprecated: Will be removed in GitLab 11.8
+ def find_branch(request, call)
+ branch_name = request.name
+ raise GRPC::InvalidArgument.new("empty Name") if branch_name.empty?
+
+ repo = Gitlab::Git::Repository.from_gitaly(request.repository, call)
+ rugged_branch = repo.find_branch(branch_name)
+ gitaly_branch = Gitaly::Branch.new(
+ name: rugged_branch.name.b,
+ target_commit: gitaly_commit_from_rugged(rugged_branch.dereferenced_target.raw_commit)
+ ) unless rugged_branch.nil?
+
+ Gitaly::FindBranchResponse.new(branch: gitaly_branch)
+ end
+
def find_all_tags(request, call)
repo = Gitlab::Git::Repository.from_gitaly(request.repository, call)