From 3dc726177fb6a476e7dc46546502cec205bef94d Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Mon, 27 Mar 2023 15:56:00 -0400 Subject: [PATCH] fix(server/cmd): ignore git commands --- server/cmd/cmd.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/server/cmd/cmd.go b/server/cmd/cmd.go index 4f474c972..44dd4b671 100644 --- a/server/cmd/cmd.go +++ b/server/cmd/cmd.go @@ -114,12 +114,23 @@ func Middleware(cfg *config.Config) wish.Middleware { if active { return } + + // Ignore git server commands. + args := s.Command() + if len(args) > 0 { + if args[0] == "git-receive-pack" || + args[0] == "git-upload-pack" || + args[0] == "git-upload-archive" { + return + } + } + ctx := context.WithValue(s.Context(), ConfigCtxKey, cfg) ctx = context.WithValue(ctx, SessionCtxKey, s) rootCmd := rootCommand() - rootCmd.SetArgs(s.Command()) - if len(s.Command()) == 0 { + rootCmd.SetArgs(args) + if len(args) == 0 { // otherwise it'll default to os.Args, which is not what we want. rootCmd.SetArgs([]string{"--help"}) }