diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-12-29 11:37:15 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-04 09:07:15 +1100 |
commit | 18ab08612687b34ccfccd0b8d12d8d73e38b8857 (patch) | |
tree | 268bb3b9872e20c75d81102c6ebffdea0e6d6819 /pkg/commands/oscommands | |
parent | b4c078d565af69bcb2f46adc20e528e53ae32908 (diff) |
introduce Common struct for passing around common stuff
Diffstat (limited to 'pkg/commands/oscommands')
-rw-r--r-- | pkg/commands/oscommands/dummies.go | 3 | ||||
-rw-r--r-- | pkg/commands/oscommands/os.go | 24 |
2 files changed, 7 insertions, 20 deletions
diff --git a/pkg/commands/oscommands/dummies.go b/pkg/commands/oscommands/dummies.go index bb6f741f1..cd2e4eca3 100644 --- a/pkg/commands/oscommands/dummies.go +++ b/pkg/commands/oscommands/dummies.go @@ -1,11 +1,10 @@ package oscommands import ( - "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/utils" ) // NewDummyOSCommand creates a new dummy OSCommand for testing func NewDummyOSCommand() *OSCommand { - return NewOSCommand(utils.NewDummyLog(), config.NewDummyAppConfig()) + return NewOSCommand(utils.NewDummyCommon()) } diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index 15e551133..f28f28c06 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -9,16 +9,14 @@ import ( "path/filepath" "strings" "sync" - "testing" "github.com/go-errors/errors" "github.com/atotto/clipboard" - "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/secureexec" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/mgutz/str" - "github.com/sirupsen/logrus" ) // Platform stores the os state @@ -44,9 +42,8 @@ func (self *RealCommander) Run(cmdObj ICmdObj) error { // OSCommand holds all the os commands type OSCommand struct { - Log *logrus.Entry + *common.Common Platform *Platform - Config config.AppConfigurer Command func(string, ...string) *exec.Cmd Getenv func(string) string @@ -92,11 +89,10 @@ func NewCmdLogEntry(cmdStr string, span string, commandLine bool) CmdLogEntry { } // NewOSCommand os command runner -func NewOSCommand(log *logrus.Entry, config config.AppConfigurer) *OSCommand { +func NewOSCommand(common *common.Common) *OSCommand { c := &OSCommand{ - Log: log, + Common: common, Platform: getPlatform(), - Config: config, Command: secureexec.Command, Getenv: os.Getenv, removeFile: os.RemoveAll, @@ -161,7 +157,7 @@ func (c *OSCommand) FileType(path string) string { // OpenFile opens a file with the given func (c *OSCommand) OpenFile(filename string) error { - commandTemplate := c.Config.GetUserConfig().OS.OpenCommand + commandTemplate := c.UserConfig.OS.OpenCommand templateValues := map[string]string{ "filename": c.Quote(filename), } @@ -173,7 +169,7 @@ func (c *OSCommand) OpenFile(filename string) error { // OpenLink opens a file with the given func (c *OSCommand) OpenLink(link string) error { c.LogCommand(fmt.Sprintf("Opening link '%s'", link), false) - commandTemplate := c.Config.GetUserConfig().OS.OpenLinkCommand + commandTemplate := c.UserConfig.OS.OpenLinkCommand templateValues := map[string]string{ "link": c.Quote(link), } @@ -429,14 +425,6 @@ type IRunner interface { type RunExpectation func(ICmdObj) (string, error) -type FakeRunner struct { - expectations []RunExpectation -} - -func (self *RealRunner) Run(cmdObj ICmdObj) error { - -} - type RealRunner struct { c *OSCommand } |