diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2019-11-01 21:30:55 +0300 |
---|---|---|
committer | Paul Okstad <pokstad@gitlab.com> | 2019-11-01 21:30:55 +0300 |
commit | 2dae0662bf408054369cd7684b2358d51f30e71d (patch) | |
tree | 7c8182c988e67e8cd711a4abc8a03545a8b0f638 /internal | |
parent | a9048f74481030e16027060a678bb6144605cbd7 (diff) |
Use Git DSL in PostUploadPack
Diffstat (limited to 'internal')
-rw-r--r-- | internal/service/smarthttp/upload_pack.go | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/internal/service/smarthttp/upload_pack.go b/internal/service/smarthttp/upload_pack.go index 569a2b30b..4bb8dc327 100644 --- a/internal/service/smarthttp/upload_pack.go +++ b/internal/service/smarthttp/upload_pack.go @@ -74,18 +74,23 @@ func (s *server) PostUploadPack(stream gitalypb.SmartHTTPService_PostUploadPackS git.WarnIfTooManyBitmaps(ctx, repoPath) - args := []string{} + var globalOpts []git.Option if featureflag.IsEnabled(ctx, featureflag.UploadPackFilter) { - args = append(args, "-c", "uploadpack.allowFilter=true", "-c", "uploadpack.allowAnySHA1InWant=true") + globalOpts = append(globalOpts, + git.ValueFlag{"-c", "uploadpack.allowFilter=true"}, + git.ValueFlag{"-c", "uploadpack.allowAnySHA1InWant=true"}, + ) } - for _, params := range req.GitConfigOptions { - args = append(args, "-c", params) + for _, o := range req.GitConfigOptions { + globalOpts = append(globalOpts, git.ValueFlag{"-c", o}) } - args = append(args, "upload-pack", "--stateless-rpc", repoPath) - - cmd, err := git.BareCommand(ctx, stdin, stdout, nil, env, args...) + cmd, err := git.SafeBareCmd(ctx, stdin, stdout, nil, env, globalOpts, git.SubCmd{ + Name: "upload-pack", + Flags: []git.Option{git.Flag{"--stateless-rpc"}}, + Args: []string{repoPath}, + }) if err != nil { return status.Errorf(codes.Unavailable, "PostUploadPack: cmd: %v", err) |