aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/command.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2022-10-15 18:49:26 +0800
committerGitHub <noreply@github.com>2022-10-15 12:49:26 +0200
commitd98c5db58fdeded983bf5c0fe781fd7b77a1235f (patch)
tree2816c975613f2f44b80bdd9cba01ebb1ee6bc9e4 /modules/git/command.go
parent7917123209d7974662baccf21346f1989247550a (diff)
downloadgitea-d98c5db58fdeded983bf5c0fe781fd7b77a1235f.tar.gz
gitea-d98c5db58fdeded983bf5c0fe781fd7b77a1235f.zip
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>
Diffstat (limited to 'modules/git/command.go')
-rw-r--r--modules/git/command.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/git/command.go b/modules/git/command.go
index b24d32dbe8..8ebd8898fb 100644
--- a/modules/git/command.go
+++ b/modules/git/command.go
@@ -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