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
32 32
33// Command represents a command with its subcommands or arguments.33// Command represents a command with its subcommands or arguments.
34type Command struct {34type Command struct {
35 name string35 name string
36 args []string36 args []string
37 parentContext context.Context37 parentContext context.Context
38 desc string38 desc string
39 globalArgsLength int
39}40}
40 41
41func (c *Command) String() string {42func (c *Command) String() string {
@@ -51,9 +52,10 @@ func NewCommand(ctx context.Context, args ...string) *Command { · 9 unmodified lines
51 cargs := make([]string, len(globalCommandArgs))52 cargs := make([]string, len(globalCommandArgs))
52 copy(cargs, globalCommandArgs)53 copy(cargs, globalCommandArgs)
53 return &Command{54 return &Command{
54 name: GitExecutable,55 name: GitExecutable,
55 args: append(cargs, args...),56 args: append(cargs, args...),
56 parentContext: ctx,57 parentContext: ctx,
58 globalArgsLength: len(globalCommandArgs),
57 }59 }
58}60}
59 61
@@ -140,7 +142,7 @@ func (c *Command) RunWithContext(rc *RunContext) error { · 80 unmodified lines
140 142
141 desc := c.desc143 desc := c.desc
142 if desc == "" {144 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)
144 }146 }
145 147
146 ctx, cancel, finished := process.GetManager().AddContextTimeout(c.parentContext, rc.Timeout, desc)148 ctx, cancel, finished := process.GetManager().AddContextTimeout(c.parentContext, rc.Timeout, desc)