Skip to content

Commit

Permalink
fix(server/cmd): ignore git commands
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed May 2, 2023
1 parent 0bff6ce commit 3dc7261
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions server/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
}
Expand Down

0 comments on commit 3dc7261

Please sign in to comment.