1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
package operations
import (
"context"
"gitlab.com/gitlab-org/gitaly/v14/client"
"gitlab.com/gitlab-org/gitaly/v14/internal/git"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/quarantine"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/updateref"
"gitlab.com/gitlab-org/gitaly/v14/internal/git2go"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/hook"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/rubyserver"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
)
type Server struct {
gitalypb.UnimplementedOperationServiceServer
cfg config.Cfg
ruby *rubyserver.Server
hookManager hook.Manager
locator storage.Locator
conns *client.Pool
git2go git2go.Executor
gitCmdFactory git.CommandFactory
catfileCache catfile.Cache
updater *updateref.UpdaterWithHooks
}
// NewServer creates a new instance of a grpc OperationServiceServer
func NewServer(
cfg config.Cfg,
rs *rubyserver.Server,
hookManager hook.Manager,
locator storage.Locator,
conns *client.Pool,
gitCmdFactory git.CommandFactory,
catfileCache catfile.Cache,
) *Server {
return &Server{
ruby: rs,
cfg: cfg,
hookManager: hookManager,
locator: locator,
conns: conns,
git2go: git2go.NewExecutor(cfg, locator),
gitCmdFactory: gitCmdFactory,
catfileCache: catfileCache,
updater: updateref.NewUpdaterWithHooks(cfg, hookManager, gitCmdFactory, catfileCache),
}
}
func (s *Server) localrepo(repo repository.GitRepo) *localrepo.Repo {
return localrepo.New(s.gitCmdFactory, s.catfileCache, repo, s.cfg)
}
func (s *Server) quarantinedRepo(
ctx context.Context, repo *gitalypb.Repository, flags ...featureflag.FeatureFlag,
) (*quarantine.Dir, *localrepo.Repo, error) {
for _, flag := range flags {
if flag.IsDisabled(ctx) {
return nil, s.localrepo(repo), nil
}
}
quarantineDir, err := quarantine.New(ctx, repo, s.locator)
if err != nil {
return nil, nil, helper.ErrInternalf("creating object quarantine: %w", err)
}
quarantineRepo := s.localrepo(quarantineDir.QuarantinedRepo())
return quarantineDir, quarantineRepo, nil
}
|