History

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.

zeripath committed 4 years ago

Commit 41b60d91 parent 793ce9d1 file · +10 −8Browse files

Showing the changes to modules/git/command.go (1 of 1 file). Show all

Unified · Split

modules/git/command.go+10−8
@@ -32,10 +32,11 @@ const DefaultLocale = "C" · 31 unmodified lines
3232
3333 // Command represents a command with its subcommands or arguments.
3434 type Command struct {
35− name string
36− args []string
37− parentContext context.Context
38− desc string
35+ name string
36+ args []string
37+ parentContext context.Context
38+ desc string
39+ globalArgsLength int
3940 }
4041
4142 func (c *Command) String() string {
@@ -51,9 +52,10 @@ func NewCommand(ctx context.Context, args ...string) *Command { · 9 unmodified lines
5152 cargs := make([]string, len(globalCommandArgs))
5253 copy(cargs, globalCommandArgs)
5354 return &Command{
54− name: GitExecutable,
55− args: append(cargs, args...),
56− parentContext: ctx,
55+ name: GitExecutable,
56+ args: append(cargs, args...),
57+ parentContext: ctx,
58+ globalArgsLength: len(globalCommandArgs),
5759 }
5860 }
5961
@@ -140,7 +142,7 @@ func (c *Command) RunWithContext(rc *RunContext) error { · 80 unmodified lines
140142
141143 desc := c.desc
142144 if desc == "" {
143− desc = fmt.Sprintf("%s %s [repo_path: %s]", c.name, strings.Join(c.args, " "), rc.Dir)
145+ desc = fmt.Sprintf("%s %s [repo_path: %s]", c.name, strings.Join(c.args[c.globalArgsLength:], " "), rc.Dir)
144146 }
145147
146148 ctx, cancel, finished := process.GetManager().AddContextTimeout(c.parentContext, rc.Timeout, desc)