mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	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>
This commit is contained in:
		| @@ -32,10 +32,11 @@ const DefaultLocale = "C" | |||||||
|  |  | ||||||
| // Command represents a command with its subcommands or arguments. | // Command represents a command with its subcommands or arguments. | ||||||
| type Command struct { | type Command struct { | ||||||
| 	name          string | 	name             string | ||||||
| 	args          []string | 	args             []string | ||||||
| 	parentContext context.Context | 	parentContext    context.Context | ||||||
| 	desc          string | 	desc             string | ||||||
|  | 	globalArgsLength int | ||||||
| } | } | ||||||
|  |  | ||||||
| func (c *Command) String() string { | func (c *Command) String() string { | ||||||
| @@ -51,9 +52,10 @@ func NewCommand(ctx context.Context, args ...string) *Command { | |||||||
| 	cargs := make([]string, len(globalCommandArgs)) | 	cargs := make([]string, len(globalCommandArgs)) | ||||||
| 	copy(cargs, globalCommandArgs) | 	copy(cargs, globalCommandArgs) | ||||||
| 	return &Command{ | 	return &Command{ | ||||||
| 		name:          GitExecutable, | 		name:             GitExecutable, | ||||||
| 		args:          append(cargs, args...), | 		args:             append(cargs, args...), | ||||||
| 		parentContext: ctx, | 		parentContext:    ctx, | ||||||
|  | 		globalArgsLength: len(globalCommandArgs), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -140,7 +142,7 @@ func (c *Command) RunWithContext(rc *RunContext) error { | |||||||
|  |  | ||||||
| 	desc := c.desc | 	desc := c.desc | ||||||
| 	if 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) | 	ctx, cancel, finished := process.GetManager().AddContextTimeout(c.parentContext, rc.Timeout, desc) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 zeripath
					zeripath