1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-04 10:34:55 +02:00

use tempdir in tests to prevent polluting worktree

This commit is contained in:
Jesse Duffield 2022-11-13 14:10:18 +11:00
parent ea28529cbb
commit df3cd941d7
2 changed files with 5 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package git_commands
import (
"os"
"github.com/go-errors/errors"
gogit "github.com/jesseduffield/go-git/v5"
"github.com/jesseduffield/lazygit/pkg/commands/git_config"
@ -70,6 +72,7 @@ func buildGitCommon(deps commonDeps) *GitCommon {
GetenvFn: getenv,
Cmd: cmd,
RemoveFileFn: removeFile,
TempDir: os.TempDir(),
})
gitCommon.dotGitDir = deps.dotGitDir

View File

@ -19,6 +19,7 @@ type OSCommandDeps struct {
GetenvFn func(string) string
RemoveFileFn func(string) error
Cmd *CmdObjBuilder
TempDir string
}
func NewDummyOSCommandWithDeps(deps OSCommandDeps) *OSCommand {
@ -38,6 +39,7 @@ func NewDummyOSCommandWithDeps(deps OSCommandDeps) *OSCommand {
getenvFn: deps.GetenvFn,
removeFileFn: deps.RemoveFileFn,
guiIO: NewNullGuiIO(utils.NewDummyLog()),
tempDir: deps.TempDir,
}
}