diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-16 18:12:26 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-30 18:35:22 +1000 |
commit | ae0193698e3540787b30696fabb8368ee483e9e1 (patch) | |
tree | c72fa6acd9ce66aabe5b0f530f2b1cd390092a5e /pkg/commands | |
parent | 6b4a6384156451203bd4559f65563f03dbbdd5df (diff) |
Log when directory is changed
Diffstat (limited to 'pkg/commands')
-rw-r--r-- | pkg/commands/git_commands/worktree.go | 4 | ||||
-rw-r--r-- | pkg/commands/oscommands/cmd_obj.go | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/pkg/commands/git_commands/worktree.go b/pkg/commands/git_commands/worktree.go index 922dbb957..de3711628 100644 --- a/pkg/commands/git_commands/worktree.go +++ b/pkg/commands/git_commands/worktree.go @@ -33,9 +33,9 @@ func (self *WorktreeCommands) Delete(worktreePath string, force bool) error { } func (self *WorktreeCommands) Detach(worktreePath string) error { - cmdArgs := NewGitCmd("checkout").Arg("--detach").WorktreePath(worktreePath).ToArgv() + cmdArgs := NewGitCmd("checkout").Arg("--detach").ToArgv() - return self.cmd.New(cmdArgs).Run() + return self.cmd.New(cmdArgs).SetWd(worktreePath).Run() } func (self *WorktreeCommands) IsCurrentWorktree(w *models.Worktree) bool { diff --git a/pkg/commands/oscommands/cmd_obj.go b/pkg/commands/oscommands/cmd_obj.go index 520a76a1b..d1cc23c67 100644 --- a/pkg/commands/oscommands/cmd_obj.go +++ b/pkg/commands/oscommands/cmd_obj.go @@ -24,6 +24,9 @@ type ICmdObj interface { AddEnvVars(...string) ICmdObj GetEnvVars() []string + // sets the working directory + SetWd(string) ICmdObj + // runs the command and returns an error if any Run() error // runs the command and returns the output as a string, and an error if any @@ -142,6 +145,12 @@ func (self *CmdObj) GetEnvVars() []string { return self.cmd.Env } +func (self *CmdObj) SetWd(wd string) ICmdObj { + self.cmd.Dir = wd + + return self +} + func (self *CmdObj) DontLog() ICmdObj { self.dontLog = true return self |