mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 08:42:32 -05:00
Add elapsed time on debug for slow git commands (#25642)
To record which command is slow, this PR adds a debug log for slow git operations. --------- Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: delvh <dev.lh@web.de>
This commit is contained in:
parent
934124c641
commit
f35ea2b09a
1 changed files with 9 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue