diff options
author | zeripath <art27@cantab.net> | 2022-03-27 10:09:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-27 10:09:56 +0100 |
commit | 41b60d94db2b51ec4554b09e51ec6523e5cdfea4 (patch) | |
tree | bf93f48c2169ad7e6e191d8638b7464650a7b2f3 | |
parent | 793ce9dacff6bd25ea2c90af9db230768b1dc240 (diff) | |
download | gitea-41b60d94db2b51ec4554b09e51ec6523e5cdfea4.tar.gz gitea-41b60d94db2b51ec4554b09e51ec6523e5cdfea4.zip |
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 <art27@cantab.net>
-rw-r--r-- | modules/git/command.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/modules/git/command.go b/modules/git/command.go index 649d9cf249..ac26ef8689 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) |