From 41b60d94db2b51ec4554b09e51ec6523e5cdfea4 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sun, 27 Mar 2022 10:09:56 +0100 Subject: [PATCH] Do not include global arguments in process manager (#19226) The git command by default adds a number of global arguments. These are not helpful to be displayed in the process manager and so should be skipped for default process descriptions. Signed-off-by: Andrew Thornton --- modules/git/command.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/git/command.go b/modules/git/command.go index 649d9cf249f3..ac26ef868955 100644 --- a/modules/git/command.go +++ b/modules/git/command.go @@ -32,10 +32,11 @@ const DefaultLocale = "C" // Command represents a command with its subcommands or arguments. type Command struct { - name string - args []string - parentContext context.Context - desc string + name string + args []string + parentContext context.Context + desc string + globalArgsLength int } func (c *Command) String() string { @@ -51,9 +52,10 @@ func NewCommand(ctx context.Context, args ...string) *Command { cargs := make([]string, len(globalCommandArgs)) copy(cargs, globalCommandArgs) return &Command{ - name: GitExecutable, - args: append(cargs, args...), - parentContext: ctx, + name: GitExecutable, + args: append(cargs, args...), + parentContext: ctx, + globalArgsLength: len(globalCommandArgs), } } @@ -140,7 +142,7 @@ func (c *Command) RunWithContext(rc *RunContext) error { desc := c.desc if desc == "" { - desc = fmt.Sprintf("%s %s [repo_path: %s]", c.name, strings.Join(c.args, " "), rc.Dir) + desc = fmt.Sprintf("%s %s [repo_path: %s]", c.name, strings.Join(c.args[c.globalArgsLength:], " "), rc.Dir) } ctx, cancel, finished := process.GetManager().AddContextTimeout(c.parentContext, rc.Timeout, desc)