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:
authorXing Xin <xingxin.xx@bytedance.com>2023-05-30 09:20:32 +0300
committerXing Xin <xingxin.xx@bytedance.com>2023-05-30 10:21:20 +0300
commit0c902825a84d2550267200eb107475ce7f9efec9 (patch)
tree84731747045b82079e82235fb2de36b03ef88251
parent58851fe18b0291ed7b11c8821c7ae548c2a96337 (diff)
ref: Cleanup unused method buildLocalBranch
The method buildLocalBranch constructs FindLocalBranchResponse, which is required by FindLocalBranchesResponse. We already finished the rolling process of replacing FindLocalBranchResponse with the shared message Branch(ff simplify_find_local_branches_response), so this method is no longer needed. Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>
-rw-r--r--internal/gitaly/service/ref/util.go37
-rw-r--r--internal/gitaly/service/ref/util_test.go188
2 files changed, 0 insertions, 225 deletions
diff --git a/internal/gitaly/service/ref/util.go b/internal/gitaly/service/ref/util.go
index 58ecc9fbb..2f68af31b 100644
--- a/internal/gitaly/service/ref/util.go
+++ b/internal/gitaly/service/ref/util.go
@@ -21,43 +21,6 @@ func parseRef(ref []byte, length int) ([][]byte, error) {
return elements, nil
}
-func buildLocalBranch(name []byte, target *gitalypb.GitCommit) *gitalypb.FindLocalBranchResponse {
- response := &gitalypb.FindLocalBranchResponse{
- Name: name,
- }
-
- if target == nil {
- return response
- }
-
- response.Commit = target
-
- // all code below exists for compatibility and must be removed after
- // https://gitlab.com/gitlab-org/gitlab/issues/205685
- response.CommitId = target.Id
- response.CommitSubject = target.Subject
-
- if author := target.Author; author != nil {
- response.CommitAuthor = &gitalypb.FindLocalBranchCommitAuthor{
- Name: author.Name,
- Email: author.Email,
- Date: author.Date,
- Timezone: author.Timezone,
- }
- }
-
- if committer := target.Committer; committer != nil {
- response.CommitCommitter = &gitalypb.FindLocalBranchCommitAuthor{
- Name: committer.Name,
- Email: committer.Email,
- Date: committer.Date,
- Timezone: committer.Timezone,
- }
- }
-
- return response
-}
-
func buildAllBranchesBranch(ctx context.Context, objectReader catfile.ObjectContentReader, elements [][]byte) (*gitalypb.FindAllBranchesResponse_Branch, error) {
target, err := catfile.GetCommit(ctx, objectReader, git.Revision(elements[1]))
if err != nil {
diff --git a/internal/gitaly/service/ref/util_test.go b/internal/gitaly/service/ref/util_test.go
deleted file mode 100644
index aa3f4f60d..000000000
--- a/internal/gitaly/service/ref/util_test.go
+++ /dev/null
@@ -1,188 +0,0 @@
-//go:build !gitaly_test_sha256
-
-package ref
-
-import (
- "testing"
-
- "gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
- "gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
- "google.golang.org/protobuf/types/known/timestamppb"
-)
-
-func TestBuildLocalBranch(t *testing.T) {
- t.Parallel()
-
- testCases := []struct {
- desc string
- in *gitalypb.GitCommit
- out *gitalypb.FindLocalBranchResponse
- }{
- {
- desc: "all required fields present",
- in: &gitalypb.GitCommit{
- Id: "b83d6e391c22777fca1ed3012fce84f633d7fed0",
- Subject: []byte("Merge branch 'branch-merged' into 'master'"),
- Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"),
- Author: &gitalypb.CommitAuthor{
- Name: []byte("Job van der Voort"),
- Email: []byte("job@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: 1474987066},
- Timezone: []byte("+0200"),
- },
- Committer: &gitalypb.CommitAuthor{
- Name: []byte("Job van der Voort"),
- Email: []byte("job@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: 1474987066},
- Timezone: []byte("+0200"),
- },
- ParentIds: []string{
- "1b12f15a11fc6e62177bef08f47bc7b5ce50b141",
- "498214de67004b1da3d820901307bed2a68a8ef6",
- },
- BodySize: 162,
- },
- out: &gitalypb.FindLocalBranchResponse{
- Name: []byte("my-branch"),
- CommitId: "b83d6e391c22777fca1ed3012fce84f633d7fed0",
- CommitSubject: []byte("Merge branch 'branch-merged' into 'master'"),
- CommitAuthor: &gitalypb.FindLocalBranchCommitAuthor{
- Name: []byte("Job van der Voort"),
- Email: []byte("job@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: 1474987066},
- Timezone: []byte("+0200"),
- },
- CommitCommitter: &gitalypb.FindLocalBranchCommitAuthor{
- Name: []byte("Job van der Voort"),
- Email: []byte("job@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: 1474987066},
- Timezone: []byte("+0200"),
- },
- Commit: &gitalypb.GitCommit{
- Id: "b83d6e391c22777fca1ed3012fce84f633d7fed0",
- Subject: []byte("Merge branch 'branch-merged' into 'master'"),
- Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"),
- Author: &gitalypb.CommitAuthor{
- Name: []byte("Job van der Voort"),
- Email: []byte("job@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: 1474987066},
- Timezone: []byte("+0200"),
- },
- Committer: &gitalypb.CommitAuthor{
- Name: []byte("Job van der Voort"),
- Email: []byte("job@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: 1474987066},
- Timezone: []byte("+0200"),
- },
- ParentIds: []string{"1b12f15a11fc6e62177bef08f47bc7b5ce50b141", "498214de67004b1da3d820901307bed2a68a8ef6"},
- BodySize: 162,
- },
- },
- },
- {
- desc: "missing author",
- in: &gitalypb.GitCommit{
- Id: "b83d6e391c22777fca1ed3012fce84f633d7fed0",
- Subject: []byte("Merge branch 'branch-merged' into 'master'"),
- Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"),
- Committer: &gitalypb.CommitAuthor{
- Name: []byte("Job van der Voort"),
- Email: []byte("job@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: 1474987066},
- Timezone: []byte("+0200"),
- },
- ParentIds: []string{
- "1b12f15a11fc6e62177bef08f47bc7b5ce50b141",
- "498214de67004b1da3d820901307bed2a68a8ef6",
- },
- BodySize: 162,
- },
- out: &gitalypb.FindLocalBranchResponse{
- Name: []byte("my-branch"),
- CommitId: "b83d6e391c22777fca1ed3012fce84f633d7fed0",
- CommitSubject: []byte("Merge branch 'branch-merged' into 'master'"),
- CommitAuthor: nil,
- CommitCommitter: &gitalypb.FindLocalBranchCommitAuthor{
- Name: []byte("Job van der Voort"),
- Email: []byte("job@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: 1474987066},
- Timezone: []byte("+0200"),
- },
- Commit: &gitalypb.GitCommit{
- Id: "b83d6e391c22777fca1ed3012fce84f633d7fed0",
- Subject: []byte("Merge branch 'branch-merged' into 'master'"),
- Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"),
- Committer: &gitalypb.CommitAuthor{
- Name: []byte("Job van der Voort"),
- Email: []byte("job@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: 1474987066},
- Timezone: []byte("+0200"),
- },
- ParentIds: []string{"1b12f15a11fc6e62177bef08f47bc7b5ce50b141", "498214de67004b1da3d820901307bed2a68a8ef6"},
- BodySize: 162,
- },
- },
- },
- {
- desc: "missing committer",
- in: &gitalypb.GitCommit{
- Id: "b83d6e391c22777fca1ed3012fce84f633d7fed0",
- Subject: []byte("Merge branch 'branch-merged' into 'master'"),
- Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"),
- Author: &gitalypb.CommitAuthor{
- Name: []byte("Job van der Voort"),
- Email: []byte("job@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: 1474987066},
- Timezone: []byte("+0200"),
- },
- ParentIds: []string{
- "1b12f15a11fc6e62177bef08f47bc7b5ce50b141",
- "498214de67004b1da3d820901307bed2a68a8ef6",
- },
- BodySize: 162,
- },
- out: &gitalypb.FindLocalBranchResponse{
- Name: []byte("my-branch"),
- CommitId: "b83d6e391c22777fca1ed3012fce84f633d7fed0",
- CommitSubject: []byte("Merge branch 'branch-merged' into 'master'"),
- CommitAuthor: &gitalypb.FindLocalBranchCommitAuthor{
- Name: []byte("Job van der Voort"),
- Email: []byte("job@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: 1474987066},
- Timezone: []byte("+0200"),
- },
- CommitCommitter: nil,
- Commit: &gitalypb.GitCommit{
- Id: "b83d6e391c22777fca1ed3012fce84f633d7fed0",
- Subject: []byte("Merge branch 'branch-merged' into 'master'"),
- Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"),
- Author: &gitalypb.CommitAuthor{
- Name: []byte("Job van der Voort"),
- Email: []byte("job@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: 1474987066},
- Timezone: []byte("+0200"),
- },
- ParentIds: []string{"1b12f15a11fc6e62177bef08f47bc7b5ce50b141", "498214de67004b1da3d820901307bed2a68a8ef6"},
- BodySize: 162,
- },
- },
- },
- {
- desc: "nil commit",
- in: nil,
- out: &gitalypb.FindLocalBranchResponse{
- Name: []byte("my-branch"),
- },
- },
- }
-
- for _, tc := range testCases {
- tc := tc
-
- t.Run(tc.desc, func(t *testing.T) {
- t.Parallel()
-
- testhelper.ProtoEqual(t, tc.out, buildLocalBranch([]byte("my-branch"), tc.in))
- })
- }
-}