From fd0ed10f847ab31e720cac9b1c7bfa0aad1dbcc2 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) Backport #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 92f902e1e929..084e6c5d9811 100644 --- a/modules/git/command.go +++ b/modules/git/command.go @@ -33,10 +33,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 { @@ -57,9 +58,10 @@ func NewCommandContext(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), } } @@ -146,7 +148,7 @@ func (c *Command) RunWithContext(rc *RunContext) error { desc := c.desc if desc == "" { - args := c.args + args := c.args[c.globalArgsLength:] var argSensitiveURLIndexes []int for i, arg := range c.args { if strings.Contains(arg, "://") && strings.Contains(arg, "@") {