Skip to content

Commit 41b60d9

Browse files
authored
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 <[email protected]>
1 parent 793ce9d commit 41b60d9

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

modules/git/command.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ const DefaultLocale = "C"
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 {
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 {
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)

0 commit comments

Comments
 (0)