From 28135a42b06348261dfd60a1bcad090c277b133b 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 4f474c97261ddd4e5be5ce030ecd165d9f869b4c..44dd4b67153b085ff990dcf6eba4c9f9ec36329f 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"}) }