3dc726177fb6a476e7dc46546502cec205bef94d
- Author
- Ayman Bagabas <ayman.bagabas@gmail.com>
- Committer
- Ayman Bagabas <ayman.bagabas@gmail.com>
- Date
Message
fix(server/cmd): ignore git commands
Diff
1diff --git a/server/cmd/cmd.go b/server/cmd/cmd.go
2index 4f474c97261ddd4e5be5ce030ecd165d9f869b4c..44dd4b67153b085ff990dcf6eba4c9f9ec36329f 100644
3--- a/server/cmd/cmd.go
4+++ b/server/cmd/cmd.go
5@@ -114,12 +114,23 @@ func Middleware(cfg *config.Config) wish.Middleware {
6 if active {
7 return
8 }
9+
10+ // Ignore git server commands.
11+ args := s.Command()
12+ if len(args) > 0 {
13+ if args[0] == "git-receive-pack" ||
14+ args[0] == "git-upload-pack" ||
15+ args[0] == "git-upload-archive" {
16+ return
17+ }
18+ }
19+
20 ctx := context.WithValue(s.Context(), ConfigCtxKey, cfg)
21 ctx = context.WithValue(ctx, SessionCtxKey, s)
22
23 rootCmd := rootCommand()
24- rootCmd.SetArgs(s.Command())
25- if len(s.Command()) == 0 {
26+ rootCmd.SetArgs(args)
27+ if len(args) == 0 {
28 // otherwise it'll default to os.Args, which is not what we want.
29 rootCmd.SetArgs([]string{"--help"})
30 }