diff --git a/modules/git/command.go b/modules/git/command.go index ac013d4ea..c38fd0469 100644 --- a/modules/git/command.go +++ b/modules/git/command.go @@ -301,6 +301,8 @@ func (c *Command) Run(opts *RunOpts) error { } defer finished() + startTime := time.Now() + cmd := exec.CommandContext(ctx, c.prog, c.args...) if opts.Env == nil { cmd.Env = os.Environ() @@ -327,7 +329,13 @@ func (c *Command) Run(opts *RunOpts) error { } } - if err := cmd.Wait(); err != nil && ctx.Err() != context.DeadlineExceeded { + err := cmd.Wait() + elapsed := time.Since(startTime) + if elapsed > time.Second { + log.Debug("slow git.Command.Run: %s (%s)", c, elapsed) + } + + if err != nil && ctx.Err() != context.DeadlineExceeded { return err }