1
0
Fork 0
forked from forgejo/forgejo

alternative to PR "improve code quality" (#21464)

This PR doesn't require new git version, and can be backported easily.

Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
wxiaoguang 2022-10-15 18:49:26 +08:00 committed by GitHub
parent 7917123209
commit d98c5db58f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 25 deletions

View file

@ -95,6 +95,18 @@ func (c *Command) AddArguments(args ...string) *Command {
return c
}
// AddDynamicArguments adds new dynamic argument(s) to the command.
// If the argument is invalid (it shouldn't happen in real life), it panics to caller
func (c *Command) AddDynamicArguments(args ...string) *Command {
for _, arg := range args {
if arg != "" && arg[0] == '-' {
panic("invalid argument: " + arg)
}
}
c.args = append(c.args, args...)
return c
}
// RunOpts represents parameters to run the command. If UseContextTimeout is specified, then Timeout is ignored.
type RunOpts struct {
Env []string