diff options
author | 6543 <6543@obermui.de> | 2022-01-25 19:15:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-25 18:15:58 +0000 |
commit | 80adbebbc8e0814d0fa0ac660d5c9452e458067b (patch) | |
tree | 50711b3b3760008b7b06abb22b452f2a12730dd2 /modules/git/command.go | |
parent | 93250bfe278f46f0344f513a13b1b396eddb7406 (diff) | |
download | gitea-80adbebbc8e0814d0fa0ac660d5c9452e458067b.tar.gz gitea-80adbebbc8e0814d0fa0ac660d5c9452e458067b.zip |
Unexport git.GlobalCommandArgs (#18376)
Unexport the git.GlobalCommandArgs variable.
Diffstat (limited to 'modules/git/command.go')
-rw-r--r-- | modules/git/command.go | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/modules/git/command.go b/modules/git/command.go index 3cf85c2d85..e8afaa0e46 100644 --- a/modules/git/command.go +++ b/modules/git/command.go @@ -20,8 +20,8 @@ import ( ) var ( - // GlobalCommandArgs global command args for external package setting - GlobalCommandArgs []string + // globalCommandArgs global command args for external package setting + globalCommandArgs []string // defaultCommandExecutionTimeout default command execution timeout duration defaultCommandExecutionTimeout = 360 * time.Second @@ -52,9 +52,9 @@ func NewCommand(args ...string) *Command { // NewCommandContext creates and returns a new Git Command based on given command and arguments. func NewCommandContext(ctx context.Context, args ...string) *Command { - // Make an explicit copy of GlobalCommandArgs, otherwise append might overwrite it - cargs := make([]string, len(GlobalCommandArgs)) - copy(cargs, GlobalCommandArgs) + // Make an explicit copy of globalCommandArgs, otherwise append might overwrite it + cargs := make([]string, len(globalCommandArgs)) + copy(cargs, globalCommandArgs) return &Command{ name: GitExecutable, args: append(cargs, args...), @@ -278,3 +278,19 @@ func (c *Command) RunTimeout(timeout time.Duration) (string, error) { func (c *Command) Run() (string, error) { return c.RunTimeout(-1) } + +// AllowLFSFiltersArgs return globalCommandArgs with lfs filter, it should only be used for tests +func AllowLFSFiltersArgs() []string { + // Now here we should explicitly allow lfs filters to run + filteredLFSGlobalArgs := make([]string, len(globalCommandArgs)) + j := 0 + for _, arg := range globalCommandArgs { + if strings.Contains(arg, "lfs") { + j-- + } else { + filteredLFSGlobalArgs[j] = arg + j++ + } + } + return filteredLFSGlobalArgs[:j] +} |