Skip to content

Commit

Permalink
Do not include global arguments in process manager (go-gitea#19226)
Browse files Browse the repository at this point in the history
Backport go-gitea#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>
  • Loading branch information
zeripath committed Mar 27, 2022
1 parent 43c1f91 commit fd0ed10
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions modules/git/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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),
}
}

Expand Down Expand Up @@ -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, "@") {
Expand Down

0 comments on commit fd0ed10

Please sign in to comment.