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 16:11:29 +0300
committerMichael Leopard <mleopard@gitlab.com>2018-12-17 16:11:29 +0300
commitc4e9f6bc5db73bb3331a088364b2c87489e9eb7c (patch)
treed57b23bde5e2f4c9732e9480905a1ad5f0aec255
parentf0c846d49c909b8052a8d1334a154a16fb27d187 (diff)
Modifying git.Command call to not require splitting output.
-rw-r--r--internal/service/ref/branches.go15
1 files changed, 3 insertions, 12 deletions
diff --git a/internal/service/ref/branches.go b/internal/service/ref/branches.go
index d0f4daf04..8cff6a1bc 100644
--- a/internal/service/ref/branches.go
+++ b/internal/service/ref/branches.go
@@ -56,13 +56,13 @@ func (s *server) FindBranch(ctx context.Context, req *gitalypb.FindBranchRequest
refName = bytes.TrimPrefix(refName, []byte("heads/"))
}
- cmd, err := git.Command(ctx, repo, "for-each-ref", "--format", "'%(objectname) %(refname)'", fmt.Sprintf("refs/heads/%s", string(refName)))
+ cmd, err := git.Command(ctx, repo, "for-each-ref", "--format", "%(objectname)", fmt.Sprintf("refs/heads/%s", string(refName)))
if err != nil {
return nil, err
}
reader := bufio.NewReader(cmd)
- line, _, err := reader.ReadLine()
+ revision, _, err := reader.ReadLine()
if err != nil {
if err == io.EOF {
return &gitalypb.FindBranchResponse{}, nil
@@ -70,15 +70,6 @@ func (s *server) FindBranch(ctx context.Context, req *gitalypb.FindBranchRequest
return nil, err
}
- var name []byte
- var revision []byte
- if splitLine := bytes.Split(line[1:len(line)-1], []byte(" ")); len(splitLine) == 2 {
- revision = splitLine[0]
- name = bytes.TrimPrefix(splitLine[1], []byte("refs/heads/"))
- } else {
- return &gitalypb.FindBranchResponse{}, nil
- }
-
commit, err := log.GetCommit(ctx, repo, string(revision))
if err != nil {
return nil, err
@@ -90,7 +81,7 @@ func (s *server) FindBranch(ctx context.Context, req *gitalypb.FindBranchRequest
return &gitalypb.FindBranchResponse{
Branch: &gitalypb.Branch{
- Name: name,
+ Name: refName,
TargetCommit: commit,
},
}, nil