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
|
package repository
import (
"bytes"
"context"
gitalyerrors "gitlab.com/gitlab-org/gitaly/v15/internal/errors"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
)
func (s *server) Fsck(ctx context.Context, req *gitalypb.FsckRequest) (*gitalypb.FsckResponse, error) {
var stdout, stderr bytes.Buffer
repo := req.GetRepository()
if repo == nil {
return nil, helper.ErrInvalidArgument(gitalyerrors.ErrEmptyRepository)
}
cmd, err := s.gitCmdFactory.New(ctx, repo,
git.SubCmd{Name: "fsck"},
git.WithStdout(&stdout),
git.WithStderr(&stderr),
)
if err != nil {
return nil, err
}
if err = cmd.Wait(); err != nil {
return &gitalypb.FsckResponse{Error: append(stdout.Bytes(), stderr.Bytes()...)}, nil
}
return &gitalypb.FsckResponse{}, nil
}
|