diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-12-29 14:33:38 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-04 09:07:15 +1100 |
commit | 43a4fa970dfceb7868959ff4da48d5507fa2f234 (patch) | |
tree | daff776e59aebeb9b814a7918a9db75d4443175f /pkg/gui | |
parent | 192a548c9957807d9d5c9c4700dffe02c1f55f03 (diff) |
WIP
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/commits_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/custom_commands.go | 8 | ||||
-rw-r--r-- | pkg/gui/diffing.go | 2 | ||||
-rw-r--r-- | pkg/gui/files_panel.go | 6 | ||||
-rw-r--r-- | pkg/gui/git_flow.go | 6 | ||||
-rw-r--r-- | pkg/gui/gpg.go | 4 | ||||
-rw-r--r-- | pkg/gui/rebase_options_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/recent_repos_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/stash_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/sub_commits_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/submodules_panel.go | 7 |
11 files changed, 23 insertions, 22 deletions
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..60d7f806c 100644 --- a/pkg/gui/custom_commands.go +++ b/pkg/gui/custom_commands.go @@ -203,7 +203,7 @@ func (gui *Gui) menuPromptFromCommand(prompt config.CustomCommandPrompt, promptR } // Run and save output - message, err := gui.GitCommand.RunWithOutput(gui.GitCommand.NewCmdObj(cmdStr)) + message, err := gui.GitCommand.Cmd.New(cmdStr).RunWithOutput() if err != nil { return gui.surfaceError(err) } @@ -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.Cmd.NewShell(cmdStr)) } loadingText := customCommand.LoadingText @@ -252,8 +252,8 @@ func (gui *Gui) handleCustomCommandKeybinding(customCommand config.CustomCommand loadingText = gui.Tr.LcRunningCustomCommandStatus } return gui.WithWaitingStatus(loadingText, func() error { - cmdObj := gui.OSCommand.NewShellCmdObjFromString(cmdStr) - if err := gui.OSCommand.WithSpan(gui.Tr.Spans.CustomCommand).Run(cmdObj); err != nil { + err := gui.OSCommand.WithSpan(gui.Tr.Spans.CustomCommand).Cmd.NewShell(cmdStr).Run() + if err != nil { return gui.surfaceError(err) } return gui.refreshSidePanels(refreshOptions{}) diff --git a/pkg/gui/diffing.go b/pkg/gui/diffing.go index 8b54e21af..e3b888066 100644 --- a/pkg/gui/diffing.go +++ b/pkg/gui/diffing.go @@ -13,7 +13,7 @@ func (gui *Gui) exitDiffMode() error { } func (gui *Gui) renderDiff() error { - cmdObj := gui.OSCommand.NewCmdObj( + cmdObj := gui.OSCommand.Cmd.New( fmt.Sprintf("git diff --submodule --no-ext-diff --color %s", gui.diffStr()), ) task := NewRunPtyTask(cmdObj.GetCmd()) diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 977f23cae..f1ac1d1a5 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -465,7 +465,7 @@ func (gui *Gui) handleCommitEditorPress() error { cmdStr := "git " + strings.Join(args, " ") return gui.runSubprocessWithSuspenseAndRefresh( - gui.GitCommand.WithSpan(gui.Tr.Spans.Commit).NewCmdObjWithLog(cmdStr), + gui.GitCommand.WithSpan(gui.Tr.Spans.Commit).Cmd.New(cmdStr).Log(), ) } @@ -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).Cmd.NewShell(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.Cmd.NewShell(command), ) }, }) diff --git a/pkg/gui/git_flow.go b/pkg/gui/git_flow.go index 29e0b2335..3c8066527 100644 --- a/pkg/gui/git_flow.go +++ b/pkg/gui/git_flow.go @@ -32,7 +32,7 @@ func (gui *Gui) gitFlowFinishBranch(gitFlowConfig string, branchName string) err } return gui.runSubprocessWithSuspenseAndRefresh( - gui.GitCommand.WithSpan(gui.Tr.Spans.GitFlowFinish).NewCmdObjWithLog("git flow " + branchType + " finish " + suffix), + gui.GitCommand.WithSpan(gui.Tr.Spans.GitFlowFinish).Cmd.New("git flow " + branchType + " finish " + suffix).Log(), ) } @@ -43,7 +43,7 @@ func (gui *Gui) handleCreateGitFlowMenu() error { } // get config - gitFlowConfig, err := gui.GitCommand.RunWithOutput(gui.GitCommand.NewCmdObj("git config --local --get-regexp gitflow")) + gitFlowConfig, err := gui.GitCommand.Cmd.New("git config --local --get-regexp gitflow").RunWithOutput() if err != nil { return gui.createErrorPanel("You need to install git-flow and enable it in this repo to use git-flow features") } @@ -56,7 +56,7 @@ func (gui *Gui) handleCreateGitFlowMenu() error { title: title, handleConfirm: func(name string) error { return gui.runSubprocessWithSuspenseAndRefresh( - gui.GitCommand.WithSpan(gui.Tr.Spans.GitFlowStart).NewCmdObjWithLog("git flow " + branchType + " start " + name), + gui.GitCommand.WithSpan(gui.Tr.Spans.GitFlowStart).Cmd.New("git flow " + branchType + " start " + name).Log(), ) }, }) diff --git a/pkg/gui/gpg.go b/pkg/gui/gpg.go index 942a5bb89..fe40f8cb8 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.Cmd.NewShell(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.Cmd.NewShell(cmdObj.ToString()) cmdObj.AddEnvVars("TERM=dumb") cmdWriter := gui.getCmdWriter() cmd := cmdObj.GetCmd() diff --git a/pkg/gui/rebase_options_panel.go b/pkg/gui/rebase_options_panel.go index 90108258e..205b9df92 100644 --- a/pkg/gui/rebase_options_panel.go +++ b/pkg/gui/rebase_options_panel.go @@ -58,7 +58,7 @@ func (gui *Gui) genericMergeCommand(command string) error { // it's impossible for a rebase to require a commit so we'll use a subprocess only if it's a merge if status == commands.REBASE_MODE_MERGING && command != REBASE_OPTION_ABORT && gui.UserConfig.Git.Merging.ManualCommit { - sub := gitCommand.NewCmdObj("git " + commandType + " --" + command) + sub := gitCommand.Cmd.New("git " + commandType + " --" + command) if sub != nil { return gui.runSubprocessWithSuspenseAndRefresh(sub) } diff --git a/pkg/gui/recent_repos_panel.go b/pkg/gui/recent_repos_panel.go index 64f99c611..5a7c58edb 100644 --- a/pkg/gui/recent_repos_panel.go +++ b/pkg/gui/recent_repos_panel.go @@ -38,7 +38,7 @@ func (gui *Gui) handleCreateRecentReposMenu() error { } func (gui *Gui) handleShowAllBranchLogs() error { - cmdObj := gui.OSCommand.NewCmdObj( + cmdObj := gui.OSCommand.Cmd.New( gui.UserConfig.Git.AllBranchesLogCmd, ) task := NewRunPtyTask(cmdObj.GetCmd()) diff --git a/pkg/gui/stash_panel.go b/pkg/gui/stash_panel.go index 3064b5a62..1f23ccc37 100644 --- a/pkg/gui/stash_panel.go +++ b/pkg/gui/stash_panel.go @@ -22,7 +22,7 @@ func (gui *Gui) stashRenderToMain() error { if stashEntry == nil { task = NewRenderStringTask(gui.Tr.NoStashEntries) } else { - cmdObj := gui.OSCommand.NewCmdObj( + cmdObj := gui.OSCommand.Cmd.New( gui.GitCommand.ShowStashEntryCmdStr(stashEntry.Index), ) task = NewRunPtyTask(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{ diff --git a/pkg/gui/submodules_panel.go b/pkg/gui/submodules_panel.go index 01cd130e0..91b28b509 100644 --- a/pkg/gui/submodules_panel.go +++ b/pkg/gui/submodules_panel.go @@ -214,7 +214,8 @@ func (gui *Gui) handleBulkSubmoduleActionsMenu() error { displayStrings: []string{gui.Tr.LcBulkInitSubmodules, style.FgGreen.Sprint(gui.GitCommand.SubmoduleBulkInitCmdObj().ToString())}, onPress: func() error { return gui.WithWaitingStatus(gui.Tr.LcRunningCommand, func() error { - if err := gui.OSCommand.WithSpan(gui.Tr.Spans.BulkInitialiseSubmodules).Run(gui.GitCommand.SubmoduleBulkInitCmdObj()); err != nil { + err := gui.GitCommand.WithSpan(gui.Tr.Spans.BulkInitialiseSubmodules).SubmoduleBulkInitCmdObj().Run() + if err != nil { return gui.surfaceError(err) } @@ -226,7 +227,7 @@ func (gui *Gui) handleBulkSubmoduleActionsMenu() error { displayStrings: []string{gui.Tr.LcBulkUpdateSubmodules, style.FgYellow.Sprint(gui.GitCommand.SubmoduleBulkUpdateCmdObj().ToString())}, onPress: func() error { return gui.WithWaitingStatus(gui.Tr.LcRunningCommand, func() error { - if err := gui.OSCommand.WithSpan(gui.Tr.Spans.BulkUpdateSubmodules).Run(gui.GitCommand.SubmoduleBulkUpdateCmdObj()); err != nil { + if err := gui.GitCommand.WithSpan(gui.Tr.Spans.BulkUpdateSubmodules).SubmoduleBulkUpdateCmdObj().Run(); err != nil { return gui.surfaceError(err) } @@ -250,7 +251,7 @@ func (gui *Gui) handleBulkSubmoduleActionsMenu() error { displayStrings: []string{gui.Tr.LcBulkDeinitSubmodules, style.FgRed.Sprint(gui.GitCommand.SubmoduleBulkDeinitCmdObj().ToString())}, onPress: func() error { return gui.WithWaitingStatus(gui.Tr.LcRunningCommand, func() error { - if err := gui.OSCommand.WithSpan(gui.Tr.Spans.BulkDeinitialiseSubmodules).Run(gui.GitCommand.SubmoduleBulkDeinitCmdObj()); err != nil { + if err := gui.GitCommand.WithSpan(gui.Tr.Spans.BulkDeinitialiseSubmodules).SubmoduleBulkDeinitCmdObj().Run(); err != nil { return gui.surfaceError(err) } |