diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-12-29 14:33:38 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-12-29 14:33:38 +1100 |
commit | 3d4470a6c072208722e5ae9a54bcb9634959a1c5 (patch) | |
tree | d00e7a25fcca71bb1d636e9d04c95e7654b826b1 /pkg | |
parent | 053a66a7be3da43aacdc7aa78e1fe757b82c4dd2 (diff) |
WIP
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/app/app.go | 2 | ||||
-rw-r--r-- | pkg/commands/branches.go | 19 | ||||
-rw-r--r-- | pkg/commands/git.go | 4 | ||||
-rw-r--r-- | pkg/commands/loading_branches.go | 90 | ||||
-rw-r--r-- | pkg/commands/loading_commits.go | 62 | ||||
-rw-r--r-- | pkg/commands/oscommands/cmd_obj.go | 29 | ||||
-rw-r--r-- | pkg/commands/oscommands/os.go | 28 | ||||
-rw-r--r-- | pkg/gui/commits_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/custom_commands.go | 4 | ||||
-rw-r--r-- | pkg/gui/files_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/gpg.go | 4 | ||||
-rw-r--r-- | pkg/gui/sub_commits_panel.go | 2 |
12 files changed, 145 insertions, 107 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go index 747f5205f..b378fdb97 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -236,7 +236,7 @@ func (app *App) setupRepo() (bool, error) { os.Exit(1) } - if err := app.OSCommand.Run(app.OSCommand.NewCmdObj("git init")); err != nil { + if err := app.OSCommand.NewCmdObj("git init").Run(); err != nil { return false, err } } diff --git a/pkg/commands/branches.go b/pkg/commands/branches.go index 274168311..ee16d544e 100644 --- a/pkg/commands/branches.go +++ b/pkg/commands/branches.go @@ -11,19 +11,19 @@ import ( // NewBranch create new branch func (c *GitCommand) NewBranch(name string, base string) error { - return c.Run(c.NewCmdObj(fmt.Sprintf("git checkout -b %s %s", c.OSCommand.Quote(name), c.OSCommand.Quote(base)))) + return c.NewCmdObj(fmt.Sprintf("git checkout -b %s %s", c.OSCommand.Quote(name), c.OSCommand.Quote(base))).Run() } // CurrentBranchName get the current branch name and displayname. // the first returned string is the name and the second is the displayname // e.g. name is 123asdf and displayname is '(HEAD detached at 123asdf)' func (c *GitCommand) CurrentBranchName() (string, string, error) { - branchName, err := c.RunWithOutput(c.NewCmdObj("git symbolic-ref --short HEAD")) + branchName, err := c.NewCmdObj("git symbolic-ref --short HEAD").RunWithOutput() if err == nil && branchName != "HEAD\n" { trimmedBranchName := strings.TrimSpace(branchName) return trimmedBranchName, trimmedBranchName, nil } - output, err := c.RunWithOutput(c.NewCmdObj("git branch --contains")) + output, err := c.NewCmdObj("git branch --contains").RunWithOutput() if err != nil { return "", "", err } @@ -47,7 +47,7 @@ func (c *GitCommand) DeleteBranch(branch string, force bool) error { command = "git branch -D" } - return c.OSCommand.Run(c.OSCommand.NewCmdObj(fmt.Sprintf("%s %s", command, c.OSCommand.Quote(branch)))) + return c.NewCmdObj(fmt.Sprintf("%s %s", command, c.OSCommand.Quote(branch))).Run() } // Checkout checks out a branch (or commit), with --force if you set the force arg to true @@ -62,24 +62,23 @@ func (c *GitCommand) Checkout(branch string, options CheckoutOptions) error { forceArg = " --force" } - cmdObj := c.NewCmdObj(fmt.Sprintf("git checkout%s %s", forceArg, c.OSCommand.Quote(branch))). + return c.NewCmdObj(fmt.Sprintf("git checkout%s %s", forceArg, c.OSCommand.Quote(branch))). // prevents git from prompting us for input which would freeze the program // TODO: see if this is actually needed here AddEnvVars("GIT_TERMINAL_PROMPT=0"). - AddEnvVars(options.EnvVars...) - - return c.OSCommand.Run(cmdObj) + AddEnvVars(options.EnvVars...). + Run() } // GetBranchGraph gets the color-formatted graph of the log for the given branch // Currently it limits the result to 100 commits, but when we get async stuff // working we can do lazy loading func (c *GitCommand) GetBranchGraph(branchName string) (string, error) { - return c.OSCommand.RunWithOutput(c.GetBranchGraphCmdObj(branchName)) + return c.GetBranchGraphCmdObj(branchName).RunWithOutput() } func (c *GitCommand) GetUpstreamForBranch(branchName string) (string, error) { - output, err := c.RunWithOutput(c.NewCmdObj(fmt.Sprintf("git rev-parse --abbrev-ref --symbolic-full-name %s@{u}", c.OSCommand.Quote(branchName)))) + output, err := c.NewCmdObj(fmt.Sprintf("git rev-parse --abbrev-ref --symbolic-full-name %s@{u}", c.OSCommand.Quote(branchName))).RunWithOutput() return strings.TrimSpace(output), err } diff --git a/pkg/commands/git.go b/pkg/commands/git.go index dd3879b82..32062ccb4 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -247,6 +247,10 @@ func (c *GitCommand) RunWithOutput(cmdObj oscommands.ICmdObj) (string, error) { } } +func (c *GitCommand) RunLineOutputCmd(cmdObj oscommands.ICmdObj, onLine func(line string) (bool, error)) error { + return c.OSCommand.RunLineOutputCmd(cmdObj, onLine) +} + func (c *GitCommand) NewCmdObj(cmdStr string) oscommands.ICmdObj { return c.OSCommand.NewCmdObj(cmdStr).AddEnvVars("GIT_OPTIONAL_LOCKS=0") } diff --git a/pkg/commands/loading_branches.go b/pkg/commands/loading_branches.go index 0c850649f..802bdb30e 100644 --- a/pkg/commands/loading_branches.go +++ b/pkg/commands/loading_branches.go @@ -42,6 +42,51 @@ func NewBranchListBuilder( } } +// Build the list of branches for the current repo +func (b *BranchListBuilder) Build() []*models.Branch { + branches := b.obtainBranches() + + reflogBranches := b.obtainReflogBranches() + + // loop through reflog branches. If there is a match, merge them, then remove it from the branches and keep it in the reflog branches + branchesWithRecency := make([]*models.Branch, 0) +outer: + for _, reflogBranch := range reflogBranches { + for j, branch := range branches { + if branch.Head { + continue + } + if strings.EqualFold(reflogBranch.Name, branch.Name) { + branch.Recency = reflogBranch.Recency + branchesWithRecency = append(branchesWithRecency, branch) + branches = append(branches[0:j], branches[j+1:]...) + continue outer + } + } + } + + branches = append(branchesWithRecency, branches...) + + foundHead := false + for i, branch := range branches { + if branch.Head { + foundHead = true + branch.Recency = " *" + branches = append(branches[0:i], branches[i+1:]...) + branches = append([]*models.Branch{branch}, branches...) + break + } + } + if !foundHead { + currentBranchName, currentBranchDisplayName, err := b.getCurrentBranchName() + if err != nil { + panic(err) + } + branches = append([]*models.Branch{{Name: currentBranchName, DisplayName: currentBranchDisplayName, Head: true, Recency: " *"}}, branches...) + } + return branches +} + func (b *BranchListBuilder) obtainBranches() []*models.Branch { output, err := b.getRawBranches() if err != nil { @@ -103,51 +148,6 @@ func (b *BranchListBuilder) obtainBranches() []*models.Branch { return branches } -// Build the list of branches for the current repo -func (b *BranchListBuilder) Build() []*models.Branch { - branches := b.obtainBranches() - - reflogBranches := b.obtainReflogBranches() - - // loop through reflog branches. If there is a match, merge them, then remove it from the branches and keep it in the reflog branches - branchesWithRecency := make([]*models.Branch, 0) -outer: - for _, reflogBranch := range reflogBranches { - for j, branch := range branches { - if branch.Head { - continue - } - if strings.EqualFold(reflogBranch.Name, branch.Name) { - branch.Recency = reflogBranch.Recency - branchesWithRecency = append(branchesWithRecency, branch) - branches = append(branches[0:j], branches[j+1:]...) - continue outer - } - } - } - - branches = append(branchesWithRecency, branches...) - - foundHead := false - for i, branch := range branches { - if branch.Head { - foundHead = true - branch.Recency = " *" - branches = append(branches[0:i], branches[i+1:]...) - branches = append([]*models.Branch{branch}, branches...) - break - } - } - if !foundHead { - currentBranchName, currentBranchDisplayName, err := b.getCurrentBranchName() - if err != nil { - panic(err) - } - branches = append([]*models.Branch{{Name: currentBranchName, DisplayName: currentBranchDisplayName, Head: true, Recency: " *"}}, branches...) - } - return branches -} - // TODO: only look at the new reflog commits, and otherwise store the recencies in // int form against the branch to recalculate the time ago func (b *BranchListBuilder) obtainReflogBranches() []*models.Branch { diff --git a/pkg/commands/loading_commits.go b/pkg/commands/loading_commits.go index 52955eef3..736c0fd26 100644 --- a/pkg/commands/loading_commits.go +++ b/pkg/commands/loading_commits.go @@ -11,9 +11,8 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/gui/style" - "github.com/jesseduffield/lazygit/pkg/i18n" - "github.com/sirupsen/logrus" ) // context: @@ -29,24 +28,29 @@ const SEPARATION_CHAR = "|" // CommitListBuilder returns a list of Branch objects for the current repo type CommitListBuilder struct { - Log *logrus.Entry - GitCommand *GitCommand - OSCommand *oscommands.OSCommand - Tr *i18n.TranslationSet + *common.Common + cmd oscommands.ICmdObjBuilder + + getCurrentBranchName func() (string, string, error) + getRebaseMode func() (string, error) + readFile func(filename string) ([]byte, error) + dotGitDir string } // NewCommitListBuilder builds a new commit list builder func NewCommitListBuilder( - log *logrus.Entry, + cmn *common.Common, gitCommand *GitCommand, osCommand *oscommands.OSCommand, - tr *i18n.TranslationSet, ) *CommitListBuilder { return &CommitListBuilder{ - Log: log, - GitCommand: gitCommand, - OSCommand: osCommand, - Tr: tr, + Common: cmn, + cmd: gitCommand, + + getCurrentBranchName: gitCommand.CurrentBranchName, + getRebaseMode: gitCommand.RebaseMode, + dotGitDir: gitCommand.DotGitDir, + readFile: ioutil.ReadFile, } } @@ -106,7 +110,7 @@ func (c *CommitListBuilder) MergeRebasingCommits(commits []*models.Commit) ([]*m } } - rebaseMode, err := c.GitCommand.RebaseMode() + rebaseMode, err := c.getRebaseMode() if err != nil { return nil, err } @@ -131,7 +135,7 @@ func (c *CommitListBuilder) MergeRebasingCommits(commits []*models.Commit) ([]*m func (c *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*models.Commit, error) { commits := []*models.Commit{} var rebasingCommits []*models.Commit - rebaseMode, err := c.GitCommand.RebaseMode() + rebaseMode, err := c.getRebaseMode() if err != nil { return nil, err } @@ -152,9 +156,7 @@ func (c *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*models.Commit passedFirstPushedCommit = true } - cmdObj := c.getLogCmd(opts) - - err = c.OSCommand.RunLineOutputCmd(cmdObj, func(line string) (bool, error) { + err = c.getLogCmd(opts).RunLineOutputCmd(func(line string) (bool, error) { if canExtractCommit(line) { commit := c.extractCommitFromLine(line) if commit.Sha == firstPushedCommit { @@ -200,7 +202,7 @@ func (c *CommitListBuilder) getHydratedRebasingCommits(rebaseMode string) ([]*mo // note that we're not filtering these as we do non-rebasing commits just because // I suspect that will cause some damage - cmdObj := c.OSCommand.NewCmdObj( + cmdObj := c.cmd.New( fmt.Sprintf( "git show %s --no-patch --oneline %s --abbrev=%d", strings.Join(commitShas, " "), @@ -211,7 +213,7 @@ func (c *CommitListBuilder) getHydratedRebasingCommits(rebaseMode string) ([]*mo hydratedCommits := make([]*models.Commit, 0, len(commits)) i := 0 - err = c.OSCommand.RunLineOutputCmd(cmdObj, func(line string) (bool, error) { + err = cmdObj.RunLineOutputCmd(func(line string) (bool, error) { if canExtractCommit(line) { commit := c.extractCommitFromLine(line) matchingCommit := commits[i] @@ -242,7 +244,7 @@ func (c *CommitListBuilder) getRebasingCommits(rebaseMode string) ([]*models.Com func (c *CommitListBuilder) getNormalRebasingCommits() ([]*models.Commit, error) { rewrittenCount := 0 - bytesContent, err := ioutil.ReadFile(filepath.Join(c.GitCommand.DotGitDir, "rebase-apply/rewritten")) + bytesContent, err := c.readFile(filepath.Join(c.dotGitDir, "rebase-apply/rewritten")) if err == nil { content := string(bytesContent) rewrittenCount = len(strings.Split(content, "\n")) @@ -250,7 +252,7 @@ func (c *CommitListBuilder) getNormalRebasingCommits() ([]*models.Commit, error) // we know we're rebasing, so lets get all the files whose names have numbers commits := []*models.Commit{} - err = filepath.Walk(filepath.Join(c.GitCommand.DotGitDir, "rebase-apply"), func(path string, f os.FileInfo, err error) error { + err = filepath.Walk(filepath.Join(c.dotGitDir, "rebase-apply"), func(path string, f os.FileInfo, err error) error { if rewrittenCount > 0 { rewrittenCount-- return nil @@ -262,7 +264,7 @@ func (c *CommitListBuilder) getNormalRebasingCommits() ([]*models.Commit, error) if !re.MatchString(f.Name()) { return nil } - bytesContent, err := ioutil.ReadFile(path) + bytesContent, err := c.readFile(path) if err != nil { return err } @@ -294,7 +296,7 @@ func (c *CommitListBuilder) getNormalRebasingCommits() ([]*models.Commit, error) // and extracts out the sha and names of commits that we still have to go // in the rebase: func (c *CommitListBuilder) getInteractiveRebasingCommits() ([]*models.Commit, error) { - bytesContent, err := ioutil.ReadFile(filepath.Join(c.GitCommand.DotGitDir, "rebase-merge/git-rebase-todo")) + bytesContent, err := c.readFile(filepath.Join(c.dotGitDir, "rebase-merge/git-rebase-todo")) if err != nil { c.Log.Error(fmt.Sprintf("error occurred reading git-rebase-todo: %s", err.Error())) // we assume an error means the file doesn't exist so we just return @@ -362,7 +364,7 @@ func (c *CommitListBuilder) setCommitMergedStatuses(refName string, commits []*m } func (c *CommitListBuilder) getMergeBase(refName string) (string, error) { - currentBranch, _, err := c.GitCommand.CurrentBranchName() + currentBranch, _, err := c.getCurrentBranchName() if err != nil { return "", err } @@ -373,7 +375,7 @@ func (c *CommitListBuilder) getMergeBase(refName string) (string, error) { } // swallowing error because it's not a big deal; probably because there are no commits yet - output, _ := c.OSCommand.RunWithOutput(c.OSCommand.NewCmdObj(fmt.Sprintf("git merge-base %s %s", c.OSCommand.Quote(refName), c.OSCommand.Quote(baseBranch)))) + output, _ := c.cmd.New(fmt.Sprintf("git merge-base %s %s", c.cmd.Quote(refName), c.cmd.Quote(baseBranch))).RunWithOutput() return ignoringWarnings(output), nil } @@ -390,7 +392,7 @@ func ignoringWarnings(commandOutput string) string { // getFirstPushedCommit returns the first commit SHA which has been pushed to the ref's upstream. // all commits above this are deemed unpushed and marked as such. func (c *CommitListBuilder) getFirstPushedCommit(refName string) (string, error) { - output, err := c.OSCommand.RunWithOutput(c.OSCommand.NewCmdObj(fmt.Sprintf("git merge-base %s %s@{u}", c.OSCommand.Quote(refName), c.OSCommand.Quote(refName)))) + output, err := c.cmd.New(fmt.Sprintf("git merge-base %s %s@{u}", c.cmd.Quote(refName), c.cmd.Quote(refName))).RunWithOutput() if err != nil { return "", err } @@ -407,10 +409,10 @@ func (c *CommitListBuilder) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj filterFlag := "" if opts.FilterPath != "" { - filterFlag = fmt.Sprintf(" --follow -- %s", c.OSCommand.Quote(opts.FilterPath)) + filterFlag = fmt.Sprintf(" --follow -- %s", c.cmd.Quote(opts.FilterPath)) } - config := c.GitCommand.UserConfig.Git.Log + config := c.UserConfig.Git.Log orderFlag := "--" + config.Order allFlag := "" @@ -418,10 +420,10 @@ func (c *CommitListBuilder) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj allFlag = " --all" } - return c.OSCommand.NewCmdObj( + return c.cmd.New( fmt.Sprintf( "git log %s %s %s --oneline %s %s --abbrev=%d %s", - c.OSCommand.Quote(opts.RefName), + c.cmd.Quote(opts.RefName), orderFlag, allFlag, prettyFormat, diff --git a/pkg/commands/oscommands/cmd_obj.go b/pkg/commands/oscommands/cmd_obj.go index 6381cf257..ff958e589 100644 --- a/pkg/commands/oscommands/cmd_obj.go +++ b/pkg/commands/oscommands/cmd_obj.go @@ -5,18 +5,27 @@ import ( ) // A command object is a general way to represent a command to be run on the -// command line. If you want to log the command you'll use .ToString() and -// if you want to run it you'll use .GetCmd() +// command line. type ICmdObj interface { GetCmd() *exec.Cmd ToString() string AddEnvVars(...string) ICmdObj GetEnvVars() []string + + Run() error + RunWithOutput() (string, error) + RunLineOutputCmd(onLine func(line string) (bool, error)) error + + // logs command + Log() } type CmdObj struct { cmdStr string cmd *exec.Cmd + + runner ICmdObjRunner + logCommand func(ICmdObj) } func (self *CmdObj) GetCmd() *exec.Cmd { @@ -36,3 +45,19 @@ func (self *CmdObj) AddEnvVars(vars ...string) ICmdObj { func (self *CmdObj) GetEnvVars() []string { return self.cmd.Env } + +func (self *CmdObj) Log() { + self.logCommand(self) +} + +func (self *CmdObj) Run() error { + return self.runner.Run(self) +} + +func (self *CmdObj) RunWithOutput() (string, error) { + return self.runner.RunWithOutput(self) +} + +func (self *CmdObj) RunLineOutputCmd(onLine func(line string) (bool, error)) error { + return self.runner.RunLineOutputCmd(self, onLine) +} diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index 931be80b7..b81e06364 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -55,7 +55,7 @@ type OSCommand struct { removeFile func(string) error - IRunner + ICmdObjRunner } // TODO: make these fields private @@ -98,7 +98,7 @@ func NewOSCommand(common *common.Common) *OSCommand { removeFile: os.RemoveAll, } - c.IRunner = &RealRunner{c: c} + c.ICmdObjRunner = &RealRunner{c: c} return c } @@ -162,7 +162,7 @@ func (c *OSCommand) OpenFile(filename string) error { "filename": c.Quote(filename), } command := utils.ResolvePlaceholderString(commandTemplate, templateValues) - err := c.Run(c.NewShellCmdObjFromString(command)) + err := c.Run(c.NewShellCmdObj(command)) return err } @@ -175,7 +175,7 @@ func (c *OSCommand) OpenLink(link string) error { } command := utils.ResolvePlaceholderString(commandTemplate, templateValues) - err := c.Run(c.NewShellCmdObjFromString(command)) + err := c.Run(c.NewShellCmdObj(command)) return err } @@ -367,6 +367,14 @@ func (c *OSCommand) RemoveFile(path string) error { // builders +type ICmdObjBuilder interface { + // returns a new command object based on the string provided + New(cmdStr string) ICmdObj + NewShell(commandStr string) ICmdObj + NewFromArgs(args []string) ICmdObj + Quote(str string) string +} + func (c *OSCommand) NewCmdObj(cmdStr string) ICmdObj { args := str.ToArgv(cmdStr) cmd := c.Command(args[0], args[1:]...) @@ -388,8 +396,8 @@ func (c *OSCommand) NewCmdObjFromArgs(args []string) ICmdObj { } } -// NewShellCmdObjFromString takes a string like `git commit` and returns an executable shell command for it -func (c *OSCommand) NewShellCmdObjFromString(commandStr string) ICmdObj { +// NewShellCmdObj takes a string like `git commit` and returns an executable shell command for it +func (c *OSCommand) NewShellCmdObj(commandStr string) ICmdObj { quotedCommand := "" // Windows does not seem to like quotes around the command if c.Platform.OS == "windows" { @@ -409,15 +417,15 @@ func (c *OSCommand) NewShellCmdObjFromString(commandStr string) ICmdObj { return c.NewCmdObj(shellCommand) } -// TODO: pick one of NewShellCmdObjFromString2 and ShellCommandFromString to use. I'm not sure -// which one actually is better, but I suspect it's NewShellCmdObjFromString2 -func (c *OSCommand) NewShellCmdObjFromString2(command string) ICmdObj { +// TODO: pick one of NewShellCmdObj2 and ShellCommandFromString to use. I'm not sure +// which one actually is better, but I suspect it's NewShellCmdObj2 +func (c *OSCommand) NewShellCmdObj2(command string) ICmdObj { return c.NewCmdObjFromArgs([]string{c.Platform.Shell, c.Platform.ShellArg, command}) } // runners -type IRunner interface { +type ICmdObjRunner interface { Run(cmdObj ICmdObj) error RunWithOutput(cmdObj ICmdObj) (string, error) RunLineOutputCmd(cmdObj ICmdObj, onLine func(line string) (bool, error)) error diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index edff7a055..f88557cdd 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -119,7 +119,7 @@ func (gui *Gui) refreshCommitsWithLimit() error { gui.Mutexes.BranchCommitsMutex.Lock() defer gui.Mutexes.BranchCommitsMutex.Unlock() - builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr) + builder := commands.NewCommitListBuilder(gui.Common, gui.GitCommand, gui.OSCommand) commits, err := builder.GetCommits( commands.GetCommitsOptions{ @@ -142,7 +142,7 @@ func (gui *Gui) refreshRebaseCommits() error { gui.Mutexes.BranchCommitsMutex.Lock() defer gui.Mutexes.BranchCommitsMutex.Unlock() - builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr) + builder := commands.NewCommitListBuilder(gui.Common, gui.GitCommand, gui.OSCommand) updatedCommits, err := builder.MergeRebasingCommits(gui.State.Commits) if err != nil { diff --git a/pkg/gui/custom_commands.go b/pkg/gui/custom_commands.go index 3abeee28a..b46df3f80 100644 --- a/pkg/gui/custom_commands.go +++ b/pkg/gui/custom_commands.go @@ -244,7 +244,7 @@ func (gui *Gui) handleCustomCommandKeybinding(customCommand config.CustomCommand } if customCommand.Subprocess { - return gui.runSubprocessWithSuspenseAndRefresh(gui.OSCommand.NewShellCmdObjFromString2(cmdStr)) + return gui.runSubprocessWithSuspenseAndRefresh(gui.OSCommand.NewShellCmdObj2(cmdStr)) } loadingText := customCommand.LoadingText @@ -252,7 +252,7 @@ func (gui *Gui) handleCustomCommandKeybinding(customCommand config.CustomCommand loadingText = gui.Tr.LcRunningCustomCommandStatus } return gui.WithWaitingStatus(loadingText, func() error { - cmdObj := gui.OSCommand.NewShellCmdObjFromString(cmdStr) + cmdObj := gui.OSCommand.NewShellCmdObj(cmdStr) if err := gui.OSCommand.WithSpan(gui.Tr.Spans.CustomCommand).Run(cmdObj); err != nil { return gui.surfaceError(err) } diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 977f23cae..4358d5abf 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -511,7 +511,7 @@ func (gui *Gui) editFileAtLine(filename string, lineNumber int) error { } return gui.runSubprocessWithSuspenseAndRefresh( - gui.OSCommand.WithSpan(gui.Tr.Spans.EditFile).NewShellCmdObjFromString(cmdStr), + gui.OSCommand.WithSpan(gui.Tr.Spans.EditFile).NewShellCmdObj(cmdStr), ) } @@ -923,7 +923,7 @@ func (gui *Gui) handleCustomCommand() error { gui.OnRunCommand(oscommands.NewCmdLogEntry(command, gui.Tr.Spans.CustomCommand, true)) return gui.runSubprocessWithSuspenseAndRefresh( - gui.OSCommand.NewShellCmdObjFromString2(command), + gui.OSCommand.NewShellCmdObj2(command), ) }, }) diff --git a/pkg/gui/gpg.go b/pkg/gui/gpg.go index 942a5bb89..a757871a1 100644 --- a/pkg/gui/gpg.go +++ b/pkg/gui/gpg.go @@ -15,7 +15,7 @@ import ( func (gui *Gui) withGpgHandling(cmdObj oscommands.ICmdObj, waitingStatus string, onSuccess func() error) error { useSubprocess := gui.GitCommand.UsingGpg() if useSubprocess { - success, err := gui.runSubprocessWithSuspense(gui.OSCommand.NewShellCmdObjFromString(cmdObj.ToString())) + success, err := gui.runSubprocessWithSuspense(gui.OSCommand.NewShellCmdObj(cmdObj.ToString())) if success && onSuccess != nil { if err := onSuccess(); err != nil { return err @@ -33,7 +33,7 @@ func (gui *Gui) withGpgHandling(cmdObj oscommands.ICmdObj, waitingStatus string, func (gui *Gui) RunAndStream(cmdObj oscommands.ICmdObj, waitingStatus string, onSuccess func() error) error { return gui.WithWaitingStatus(waitingStatus, func() error { - cmdObj := gui.OSCommand.NewShellCmdObjFromString(cmdObj.ToString()) + cmdObj := gui.OSCommand.NewShellCmdObj(cmdObj.ToString()) cmdObj.AddEnvVars("TERM=dumb") cmdWriter := gui.getCmdWriter() cmd := cmdObj.GetCmd() diff --git a/pkg/gui/sub_commits_panel.go b/pkg/gui/sub_commits_panel.go index fe2d24c40..c212e3caa 100644 --- a/pkg/gui/sub_commits_panel.go +++ b/pkg/gui/sub_commits_panel.go @@ -75,7 +75,7 @@ func (gui *Gui) handleViewSubCommitFiles() error { func (gui *Gui) switchToSubCommitsContext(refName string) error { // need to populate my sub commits - builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr) + builder := commands.NewCommitListBuilder(gui.Common, gui.GitCommand, gui.OSCommand) commits, err := builder.GetCommits( commands.GetCommitsOptions{ |