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:
parent
7917123209
commit
d98c5db58f
6 changed files with 52 additions and 25 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue