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:
authorEric Ju <eju@gitlab.com>2023-11-27 18:56:57 +0300
committerEric Ju <eju@gitlab.com>2023-11-28 19:46:09 +0300
commit73e9efa6d538c449814d8e7e7fa4ae9e2ee80154 (patch)
treecbdce44e2c921f8beecd9fb3775f993c8ad7d866
parent6f824ad13b27677e1a5d74658439ffd777978d1a (diff)
repository: Call GetFileAttributes instead of GetInfoAttributesej-issue-414855_call-GetFileAttributes
As GetInfoAttributes are being deprecated, we will be using GetFileAttributes RCP call to replace it.
-rw-r--r--internal/gitaly/server/auth_test.go13
-rw-r--r--internal/gitaly/service/repository/replicate.go34
-rw-r--r--internal/gitaly/service/repository/replicate_test.go37
3 files changed, 3 insertions, 81 deletions
diff --git a/internal/gitaly/server/auth_test.go b/internal/gitaly/server/auth_test.go
index 1c8ff4d0d..31c3e627c 100644
--- a/internal/gitaly/server/auth_test.go
+++ b/internal/gitaly/server/auth_test.go
@@ -5,7 +5,6 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
- "io"
"net"
"testing"
"time"
@@ -31,7 +30,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
- "gitlab.com/gitlab-org/gitaly/v16/streamio"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
@@ -290,20 +288,15 @@ func TestStreamingNoAuth(t *testing.T) {
ctx := testhelper.Context(t)
client := gitalypb.NewRepositoryServiceClient(conn)
- //nolint:staticcheck
- stream, err := client.GetInfoAttributes(ctx, &gitalypb.GetInfoAttributesRequest{
+
+ response, err := client.GetFileAttributes(ctx, &gitalypb.GetFileAttributesRequest{
Repository: &gitalypb.Repository{
StorageName: cfg.Storages[0].Name,
RelativePath: "new/project/path",
},
},
)
- require.NoError(t, err)
-
- _, err = io.ReadAll(streamio.NewReader(func() ([]byte, error) {
- _, err = stream.Recv()
- return nil, err
- }))
+ require.Nil(t, response)
testhelper.RequireGrpcCode(t, err, codes.Unauthenticated)
}
diff --git a/internal/gitaly/service/repository/replicate.go b/internal/gitaly/service/repository/replicate.go
index 38a90b271..65d390ca6 100644
--- a/internal/gitaly/service/repository/replicate.go
+++ b/internal/gitaly/service/repository/replicate.go
@@ -97,10 +97,6 @@ func (s *server) replicateRepository(ctx context.Context, source, target *gitaly
return fmt.Errorf("synchronizing gitconfig: %w", err)
}
- if err := s.syncInfoAttributes(ctx, source, target); err != nil {
- return fmt.Errorf("synchronizing gitattributes: %w", err)
- }
-
if replicateObjectDeduplicationNetworkMembership {
// Sync the repository object pool before fetching the repository to avoid additional
// duplication. If the object pool already exists on the target node, this will potentially
@@ -360,36 +356,6 @@ func (s *server) syncGitconfig(ctx context.Context, source, target *gitalypb.Rep
return nil
}
-func (s *server) syncInfoAttributes(ctx context.Context, source, target *gitalypb.Repository) error {
- repoClient, err := s.newRepoClient(ctx, source.GetStorageName())
- if err != nil {
- return err
- }
-
- repoPath, err := s.locator.GetRepoPath(target)
- if err != nil {
- return err
- }
-
- //nolint:staticcheck
- stream, err := repoClient.GetInfoAttributes(ctx, &gitalypb.GetInfoAttributesRequest{
- Repository: source,
- })
- if err != nil {
- return err
- }
-
- attributesPath := filepath.Join(repoPath, "info", "attributes")
- if err := s.writeFile(ctx, attributesPath, attributesFileMode, streamio.NewReader(func() ([]byte, error) {
- resp, err := stream.Recv()
- return resp.GetAttributes(), err
- })); err != nil {
- return err
- }
-
- return nil
-}
-
// syncObjectPool syncs the Git alternates file and sets up object pools as needed.
func (s *server) syncObjectPool(ctx context.Context, sourceRepoProto, targetRepoProto *gitalypb.Repository) error {
sourceObjectPoolClient, err := s.newObjectPoolClient(ctx, sourceRepoProto.GetStorageName())
diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go
index 6b3d78910..168246f88 100644
--- a/internal/gitaly/service/repository/replicate_test.go
+++ b/internal/gitaly/service/repository/replicate_test.go
@@ -108,25 +108,6 @@ func testReplicateRepository(t *testing.T, ctx context.Context) {
},
},
{
- desc: "replicate info attributes",
- setup: func(t *testing.T, cfg config.Cfg) setupData {
- source, sourcePath, target, _ := setupSourceAndTarget(t, cfg, false)
-
- // Write an info attributes file to the source repository to verify it is getting
- // created in the target repository as expected.
- // We should get rid of this with https://gitlab.com/groups/gitlab-org/-/epics/9006
- attrFilePath := filepath.Join(sourcePath, "info", "attributes")
- require.NoError(t, os.MkdirAll(filepath.Dir(attrFilePath), perm.SharedDir))
- attributesData := []byte("*.pbxproj binary\n")
- require.NoError(t, os.WriteFile(attrFilePath, attributesData, perm.SharedFile))
-
- return setupData{
- source: source,
- target: target,
- }
- },
- },
- {
desc: "replicate branch",
setup: func(t *testing.T, cfg config.Cfg) setupData {
source, sourcePath, target, _ := setupSourceAndTarget(t, cfg, false)
@@ -611,18 +592,6 @@ func testReplicateRepository(t *testing.T, ctx context.Context) {
"config file must match",
)
- // Verify info attributes matches.
- sourceAttributesData, err := os.ReadFile(filepath.Join(sourcePath, "info", "attributes"))
- if err != nil {
- require.ErrorIs(t, err, os.ErrNotExist)
- }
-
- require.Equal(t,
- string(sourceAttributesData),
- string(testhelper.MustReadFile(t, filepath.Join(targetPath, "info", "attributes"))),
- "info/attributes file must match",
- )
-
// Verify custom hooks replicated.
var targetHooks []string
targetHooksPath := filepath.Join(targetPath, repoutil.CustomHooksDir)
@@ -719,8 +688,6 @@ func TestReplicateRepository_transactional(t *testing.T) {
require.NoError(t, err)
- // There is no gitattributes file, so we vote on the empty contents of that file.
- gitattributesVote := voting.VoteFromData([]byte{})
// There is a gitconfig though, so the vote should reflect its contents.
gitconfigVote := voting.VoteFromData(testhelper.MustReadFile(t, filepath.Join(sourceRepoPath, "config")))
@@ -741,8 +708,6 @@ func TestReplicateRepository_transactional(t *testing.T) {
votes[0],
gitconfigVote,
gitconfigVote,
- gitattributesVote,
- gitattributesVote,
noHooksVote,
noHooksVote,
}
@@ -769,8 +734,6 @@ func TestReplicateRepository_transactional(t *testing.T) {
expectedVotes = []voting.Vote{
gitconfigVote,
gitconfigVote,
- gitattributesVote,
- gitattributesVote,
replicationVote,
replicationVote,
noHooksVote,