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
|
package repository
import (
"context"
"gitlab.com/gitlab-org/gitaly/v15/structerr"
"strings"
"gitlab.com/gitlab-org/gitaly/proto/v15/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/service"
)
func (s *server) Fsck(ctx context.Context, req *gitalypb.FsckRequest) (*gitalypb.FsckResponse, error) {
repository := req.GetRepository()
if err := service.ValidateRepository(repository); err != nil {
return nil, structerr.NewInvalidArgument("%w", err)
}
var output strings.Builder
cmd, err := s.gitCmdFactory.New(ctx, repository,
git.Command{
Name: "fsck",
Flags: []git.Option{
// We don't care about any progress bars.
git.Flag{Name: "--no-progress"},
// We don't want to get warning about dangling objects. It is
// expected that repositories have these and makes the signal to
// noise ratio a lot worse.
git.Flag{Name: "--no-dangling"},
},
},
git.WithStdout(&output),
git.WithStderr(&output),
)
if err != nil {
return nil, err
}
if err = cmd.Wait(); err != nil {
return &gitalypb.FsckResponse{Error: []byte(output.String())}, nil
}
return &gitalypb.FsckResponse{}, nil
}
|