diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-05 11:57:32 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-07 10:52:51 +1100 |
commit | 05fa483f4818d45b357187700079c3bdae663df2 (patch) | |
tree | fb4fe7d3fda3e8b3e3d862c7a5e1383de456fe60 /pkg/gui/submodules_panel.go | |
parent | e524e398423f8aea2961302287123085dcc5a524 (diff) |
simplify how we log commands
Diffstat (limited to 'pkg/gui/submodules_panel.go')
-rw-r--r-- | pkg/gui/submodules_panel.go | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/pkg/gui/submodules_panel.go b/pkg/gui/submodules_panel.go index 91b28b509..67af6350e 100644 --- a/pkg/gui/submodules_panel.go +++ b/pkg/gui/submodules_panel.go @@ -79,7 +79,8 @@ func (gui *Gui) removeSubmodule(submodule *models.SubmoduleConfig) error { title: gui.Tr.RemoveSubmodule, prompt: fmt.Sprintf(gui.Tr.RemoveSubmodulePrompt, submodule.Name), handleConfirm: func() error { - if err := gui.GitCommand.WithSpan(gui.Tr.Spans.RemoveSubmodule).SubmoduleDelete(submodule); err != nil { + gui.logSpan(gui.Tr.Spans.RemoveSubmodule) + if err := gui.GitCommand.SubmoduleDelete(submodule); err != nil { return gui.surfaceError(err) } @@ -105,19 +106,19 @@ func (gui *Gui) fileForSubmodule(submodule *models.SubmoduleConfig) *models.File } func (gui *Gui) resetSubmodule(submodule *models.SubmoduleConfig) error { - gitCommand := gui.GitCommand.WithSpan(gui.Tr.Spans.ResetSubmodule) + gui.logSpan(gui.Tr.Spans.ResetSubmodule) file := gui.fileForSubmodule(submodule) if file != nil { - if err := gitCommand.UnStageFile(file.Names(), file.Tracked); err != nil { + if err := gui.GitCommand.UnStageFile(file.Names(), file.Tracked); err != nil { return gui.surfaceError(err) } } - if err := gitCommand.SubmoduleStash(submodule); err != nil { + if err := gui.GitCommand.SubmoduleStash(submodule); err != nil { return gui.surfaceError(err) } - if err := gitCommand.SubmoduleReset(submodule); err != nil { + if err := gui.GitCommand.SubmoduleReset(submodule); err != nil { return gui.surfaceError(err) } @@ -140,7 +141,8 @@ func (gui *Gui) handleAddSubmodule() error { initialContent: submoduleName, handleConfirm: func(submodulePath string) error { return gui.WithWaitingStatus(gui.Tr.LcAddingSubmoduleStatus, func() error { - err := gui.GitCommand.WithSpan(gui.Tr.Spans.AddSubmodule).SubmoduleAdd(submoduleName, submodulePath, submoduleUrl) + gui.logSpan(gui.Tr.Spans.AddSubmodule) + err := gui.GitCommand.SubmoduleAdd(submoduleName, submodulePath, submoduleUrl) gui.handleCredentialsPopup(err) return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{SUBMODULES}}) @@ -160,7 +162,8 @@ func (gui *Gui) handleEditSubmoduleUrl(submodule *models.SubmoduleConfig) error initialContent: submodule.Url, handleConfirm: func(newUrl string) error { return gui.WithWaitingStatus(gui.Tr.LcUpdatingSubmoduleUrlStatus, func() error { - err := gui.GitCommand.WithSpan(gui.Tr.Spans.UpdateSubmoduleUrl).SubmoduleUpdateUrl(submodule.Name, submodule.Path, newUrl) + gui.logSpan(gui.Tr.Spans.UpdateSubmoduleUrl) + err := gui.GitCommand.SubmoduleUpdateUrl(submodule.Name, submodule.Path, newUrl) gui.handleCredentialsPopup(err) return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{SUBMODULES}}) @@ -171,7 +174,8 @@ func (gui *Gui) handleEditSubmoduleUrl(submodule *models.SubmoduleConfig) error func (gui *Gui) handleSubmoduleInit(submodule *models.SubmoduleConfig) error { return gui.WithWaitingStatus(gui.Tr.LcInitializingSubmoduleStatus, func() error { - err := gui.GitCommand.WithSpan(gui.Tr.Spans.InitialiseSubmodule).SubmoduleInit(submodule.Path) + gui.logSpan(gui.Tr.Spans.InitialiseSubmodule) + err := gui.GitCommand.SubmoduleInit(submodule.Path) gui.handleCredentialsPopup(err) return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{SUBMODULES}}) @@ -214,7 +218,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 { - err := gui.GitCommand.WithSpan(gui.Tr.Spans.BulkInitialiseSubmodules).SubmoduleBulkInitCmdObj().Run() + gui.logSpan(gui.Tr.Spans.BulkInitialiseSubmodules) + err := gui.GitCommand.SubmoduleBulkInitCmdObj().Run() if err != nil { return gui.surfaceError(err) } @@ -227,7 +232,8 @@ 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.GitCommand.WithSpan(gui.Tr.Spans.BulkUpdateSubmodules).SubmoduleBulkUpdateCmdObj().Run(); err != nil { + gui.logSpan(gui.Tr.Spans.BulkUpdateSubmodules) + if err := gui.GitCommand.SubmoduleBulkUpdateCmdObj().Run(); err != nil { return gui.surfaceError(err) } @@ -239,7 +245,8 @@ func (gui *Gui) handleBulkSubmoduleActionsMenu() error { displayStrings: []string{gui.Tr.LcSubmoduleStashAndReset, style.FgRed.Sprintf("git stash in each submodule && %s", gui.GitCommand.SubmoduleForceBulkUpdateCmdObj().ToString())}, onPress: func() error { return gui.WithWaitingStatus(gui.Tr.LcRunningCommand, func() error { - if err := gui.GitCommand.WithSpan(gui.Tr.Spans.BulkStashAndResetSubmodules).ResetSubmodules(gui.State.Submodules); err != nil { + gui.logSpan(gui.Tr.Spans.BulkStashAndResetSubmodules) + if err := gui.GitCommand.ResetSubmodules(gui.State.Submodules); err != nil { return gui.surfaceError(err) } @@ -251,7 +258,8 @@ 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.GitCommand.WithSpan(gui.Tr.Spans.BulkDeinitialiseSubmodules).SubmoduleBulkDeinitCmdObj().Run(); err != nil { + gui.logSpan(gui.Tr.Spans.BulkDeinitialiseSubmodules) + if err := gui.GitCommand.SubmoduleBulkDeinitCmdObj().Run(); err != nil { return gui.surfaceError(err) } @@ -266,7 +274,8 @@ func (gui *Gui) handleBulkSubmoduleActionsMenu() error { func (gui *Gui) handleUpdateSubmodule(submodule *models.SubmoduleConfig) error { return gui.WithWaitingStatus(gui.Tr.LcUpdatingSubmoduleStatus, func() error { - err := gui.GitCommand.WithSpan(gui.Tr.Spans.UpdateSubmodule).SubmoduleUpdate(submodule.Path) + gui.logSpan(gui.Tr.Spans.UpdateSubmodule) + err := gui.GitCommand.SubmoduleUpdate(submodule.Path) gui.handleCredentialsPopup(err) return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{SUBMODULES}}) |