1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00

start adding support for logging of commands

This commit is contained in:
Jesse Duffield
2021-04-10 16:01:46 +10:00
parent e145090046
commit bb918b579a
20 changed files with 595 additions and 487 deletions

View File

@@ -146,7 +146,7 @@ func (gui *Gui) getWindowDimensions(informationStr string, appStatus string) map
mainPanelsDirection = boxlayout.COLUMN
}
cmdLogSize := 10
cmdLogSize := 40 // TODO: make configurable
root := &boxlayout.Box{
Direction: boxlayout.ROW,

View File

@@ -5,6 +5,7 @@ import (
"strings"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/utils"
)
@@ -19,7 +20,9 @@ func (gui *Gui) handleCommitConfirm() error {
flags = "--no-verify"
}
return gui.withGpgHandling(gui.GitCommand.CommitCmdStr(message, flags), gui.Tr.CommittingStatus, func() error {
cmdStr := gui.GitCommand.CommitCmdStr(message, flags)
gui.OnRunCommand(oscommands.NewCmdLogEntry(cmdStr, "Commit", true))
return gui.withGpgHandling(cmdStr, gui.Tr.CommittingStatus, func() error {
_ = gui.returnFromContext()
gui.clearEditorView(gui.Views.CommitMessage)
return nil

View File

@@ -12,7 +12,7 @@ func (gui *Gui) handleCreateDiscardMenu() error {
{
displayString: gui.Tr.LcDiscardAllChanges,
onPress: func() error {
if err := gui.GitCommand.DiscardAllDirChanges(node); err != nil {
if err := gui.GitCommand.WithSpan("Discard all changes in directory").DiscardAllDirChanges(node); err != nil {
return gui.surfaceError(err)
}
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{FILES}})
@@ -24,7 +24,7 @@ func (gui *Gui) handleCreateDiscardMenu() error {
menuItems = append(menuItems, &menuItem{
displayString: gui.Tr.LcDiscardUnstagedChanges,
onPress: func() error {
if err := gui.GitCommand.DiscardUnstagedDirChanges(node); err != nil {
if err := gui.GitCommand.WithSpan("Discard unstaged changes in directory").DiscardUnstagedDirChanges(node); err != nil {
return gui.surfaceError(err)
}
@@ -52,7 +52,8 @@ func (gui *Gui) handleCreateDiscardMenu() error {
{
displayString: gui.Tr.LcDiscardAllChanges,
onPress: func() error {
if err := gui.GitCommand.DiscardAllFileChanges(file); err != nil {
gui.Log.Warn("HA?")
if err := gui.GitCommand.WithSpan("Discard all changes in file").DiscardAllFileChanges(file); err != nil {
return gui.surfaceError(err)
}
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{FILES}})
@@ -64,7 +65,7 @@ func (gui *Gui) handleCreateDiscardMenu() error {
menuItems = append(menuItems, &menuItem{
displayString: gui.Tr.LcDiscardUnstagedChanges,
onPress: func() error {
if err := gui.GitCommand.DiscardUnstagedFileChanges(file); err != nil {
if err := gui.GitCommand.WithSpan("Discard all unstaged changes in file").DiscardUnstagedFileChanges(file); err != nil {
return gui.surfaceError(err)
}

View File

@@ -8,6 +8,7 @@ import (
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/gui/filetree"
"github.com/jesseduffield/lazygit/pkg/utils"
@@ -218,11 +219,11 @@ func (gui *Gui) handleFilePress() error {
}
if file.HasUnstagedChanges {
if err := gui.GitCommand.StageFile(file.Name); err != nil {
if err := gui.GitCommand.WithSpan("Stage file").StageFile(file.Name); err != nil {
return gui.surfaceError(err)
}
} else {
if err := gui.GitCommand.UnStageFile(file.Names(), file.Tracked); err != nil {
if err := gui.GitCommand.WithSpan("Unstage file").UnStageFile(file.Names(), file.Tracked); err != nil {
return gui.surfaceError(err)
}
}
@@ -234,12 +235,12 @@ func (gui *Gui) handleFilePress() error {
}
if node.GetHasUnstagedChanges() {
if err := gui.GitCommand.StageFile(node.Path); err != nil {
if err := gui.GitCommand.WithSpan("Stage file").StageFile(node.Path); err != nil {
return gui.surfaceError(err)
}
} else {
// pretty sure it doesn't matter that we're always passing true here
if err := gui.GitCommand.UnStageFile([]string{node.Path}, true); err != nil {
if err := gui.GitCommand.WithSpan("Unstage file").UnStageFile([]string{node.Path}, true); err != nil {
return gui.surfaceError(err)
}
}
@@ -268,9 +269,9 @@ func (gui *Gui) focusAndSelectFile() error {
func (gui *Gui) handleStageAll() error {
var err error
if gui.allFilesStaged() {
err = gui.GitCommand.UnstageAll()
err = gui.GitCommand.WithSpan("Unstage all files").UnstageAll()
} else {
err = gui.GitCommand.StageAll()
err = gui.GitCommand.WithSpan("Stage all files").StageAll()
}
if err != nil {
_ = gui.surfaceError(err)
@@ -293,10 +294,12 @@ func (gui *Gui) handleIgnoreFile() error {
return gui.createErrorPanel("Cannot ignore .gitignore")
}
gitCommand := gui.GitCommand.WithSpan("Ignore file")
unstageFiles := func() error {
return node.ForEachFile(func(file *models.File) error {
if file.HasStagedChanges {
if err := gui.GitCommand.UnStageFile(file.Names(), file.Tracked); err != nil {
if err := gitCommand.UnStageFile(file.Names(), file.Tracked); err != nil {
return err
}
}
@@ -315,11 +318,11 @@ func (gui *Gui) handleIgnoreFile() error {
return err
}
if err := gui.GitCommand.RemoveTrackedFiles(node.GetPath()); err != nil {
if err := gitCommand.RemoveTrackedFiles(node.GetPath()); err != nil {
return err
}
if err := gui.GitCommand.Ignore(node.GetPath()); err != nil {
if err := gitCommand.Ignore(node.GetPath()); err != nil {
return err
}
return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{FILES}})
@@ -331,7 +334,7 @@ func (gui *Gui) handleIgnoreFile() error {
return err
}
if err := gui.GitCommand.Ignore(node.GetPath()); err != nil {
if err := gitCommand.Ignore(node.GetPath()); err != nil {
return gui.surfaceError(err)
}
@@ -364,7 +367,7 @@ func (gui *Gui) commitPrefixConfigForRepo() *config.CommitPrefixConfig {
func (gui *Gui) prepareFilesForCommit() error {
noStagedFiles := len(gui.stagedFiles()) == 0
if noStagedFiles && gui.Config.GetUserConfig().Gui.SkipNoStagedFilesWarning {
err := gui.GitCommand.StageAll()
err := gui.GitCommand.WithSpan("Stage all files").StageAll()
if err != nil {
return err
}
@@ -419,7 +422,7 @@ func (gui *Gui) promptToStageAllAndRetry(retry func() error) error {
title: gui.Tr.NoFilesStagedTitle,
prompt: gui.Tr.NoFilesStagedPrompt,
handleConfirm: func() error {
if err := gui.GitCommand.StageAll(); err != nil {
if err := gui.GitCommand.WithSpan("Stage all files").StageAll(); err != nil {
return gui.surfaceError(err)
}
if err := gui.refreshFilesAndSubmodules(); err != nil {
@@ -448,7 +451,9 @@ func (gui *Gui) handleAmendCommitPress() error {
title: strings.Title(gui.Tr.AmendLastCommit),
prompt: gui.Tr.SureToAmend,
handleConfirm: func() error {
return gui.withGpgHandling(gui.GitCommand.AmendHeadCmdStr(), gui.Tr.AmendingStatus, nil)
cmdStr := gui.GitCommand.AmendHeadCmdStr()
gui.OnRunCommand(oscommands.NewCmdLogEntry(cmdStr, "Amend commit", true))
return gui.withGpgHandling(cmdStr, gui.Tr.AmendingStatus, nil)
},
})
}
@@ -465,7 +470,7 @@ func (gui *Gui) handleCommitEditorPress() error {
}
return gui.runSubprocessWithSuspenseAndRefresh(
gui.OSCommand.PrepareSubProcess("git", "commit"),
gui.OSCommand.WithSpan("Commit").PrepareSubProcess("git", "commit"),
)
}
@@ -476,7 +481,7 @@ func (gui *Gui) editFile(filename string) error {
}
return gui.runSubprocessWithSuspenseAndRefresh(
gui.OSCommand.PrepareShellSubProcess(cmdStr),
gui.OSCommand.WithSpan("Edit file").PrepareShellSubProcess(cmdStr),
)
}
@@ -654,6 +659,7 @@ func (gui *Gui) pullFiles(opts PullFilesOptions) error {
mode := gui.Config.GetUserConfig().Git.Pull.Mode
// TODO: this doesn't look like a good idea. Why the goroutine?
go utils.Safe(func() { _ = gui.pullWithMode(mode, opts) })
return nil
@@ -663,7 +669,9 @@ func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error {
gui.Mutexes.FetchMutex.Lock()
defer gui.Mutexes.FetchMutex.Unlock()
err := gui.GitCommand.Fetch(
gitCommand := gui.GitCommand.WithSpan("Pull")
err := gitCommand.Fetch(
commands.FetchOptions{
PromptUserForCredential: gui.promptUserForCredential,
RemoteName: opts.RemoteName,
@@ -677,13 +685,13 @@ func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error {
switch mode {
case "rebase":
err := gui.GitCommand.RebaseBranch("FETCH_HEAD")
err := gitCommand.RebaseBranch("FETCH_HEAD")
return gui.handleGenericMergeCommandResult(err)
case "merge":
err := gui.GitCommand.Merge("FETCH_HEAD", commands.MergeOpts{})
err := gitCommand.Merge("FETCH_HEAD", commands.MergeOpts{})
return gui.handleGenericMergeCommandResult(err)
case "ff-only":
err := gui.GitCommand.Merge("FETCH_HEAD", commands.MergeOpts{FastForwardOnly: true})
err := gitCommand.Merge("FETCH_HEAD", commands.MergeOpts{FastForwardOnly: true})
return gui.handleGenericMergeCommandResult(err)
default:
return gui.createErrorPanel(fmt.Sprintf("git pull mode '%s' unrecognised", mode))
@@ -696,7 +704,7 @@ func (gui *Gui) pushWithForceFlag(force bool, upstream string, args string) erro
}
go utils.Safe(func() {
branchName := gui.getCheckedOutBranch().Name
err := gui.GitCommand.Push(branchName, force, upstream, args, gui.promptUserForCredential)
err := gui.GitCommand.WithSpan("Push").Push(branchName, force, upstream, args, gui.promptUserForCredential)
if err != nil && !force && strings.Contains(err.Error(), "Updates were rejected") {
forcePushDisabled := gui.Config.GetUserConfig().Git.DisableForcePushing
if forcePushDisabled {
@@ -785,7 +793,7 @@ func (gui *Gui) handleSwitchToMerge() error {
}
func (gui *Gui) openFile(filename string) error {
if err := gui.OSCommand.OpenFile(filename); err != nil {
if err := gui.OSCommand.WithSpan("Open file").OpenFile(filename); err != nil {
return gui.surfaceError(err)
}
return nil
@@ -804,6 +812,7 @@ func (gui *Gui) handleCustomCommand() error {
return gui.prompt(promptOpts{
title: gui.Tr.CustomCommand,
handleConfirm: func(command string) error {
gui.OnRunCommand(oscommands.NewCmdLogEntry(command, "Custom command", true))
return gui.runSubprocessWithSuspenseAndRefresh(
gui.OSCommand.PrepareShellSubProcess(command),
)
@@ -816,13 +825,13 @@ func (gui *Gui) handleCreateStashMenu() error {
{
displayString: gui.Tr.LcStashAllChanges,
onPress: func() error {
return gui.handleStashSave(gui.GitCommand.StashSave)
return gui.handleStashSave(gui.GitCommand.WithSpan("Stash all changes").StashSave)
},
},
{
displayString: gui.Tr.LcStashStagedChanges,
onPress: func() error {
return gui.handleStashSave(gui.GitCommand.StashSaveStagedChanges)
return gui.handleStashSave(gui.GitCommand.WithSpan("Stash staged changes").StashSaveStagedChanges)
},
},
}

View File

@@ -56,7 +56,7 @@ func (gui *Gui) handleCreateGitFlowMenu() error {
title: title,
handleConfirm: func(name string) error {
return gui.runSubprocessWithSuspenseAndRefresh(
gui.OSCommand.PrepareSubProcess("git", "flow", branchType, "start", name),
gui.OSCommand.WithSpan("Git Flow").PrepareSubProcess("git", "flow", branchType, "start", name),
)
},
})

View File

@@ -111,7 +111,8 @@ type Gui struct {
PauseBackgroundThreads bool
// Log of the commands that get run, to be displayed to the user.
CmdLog []string
CmdLog []string
OnRunCommand func(entry oscommands.CmdLogEntry)
}
type listPanelState struct {
@@ -470,15 +471,30 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom
gui.watchFilesForChanges()
oSCommand.SetOnRunCommand(func(cmdStr string) {
gui.Log.Warn("HHMM")
gui.CmdLog = append(gui.CmdLog, cmdStr)
if gui.Views.CmdLog != nil {
fmt.Fprintln(gui.Views.CmdLog, cmdStr)
gui.Log.Warn("HHMM")
gui.Log.Warn(cmdStr)
onRunCommand := func() func(entry oscommands.CmdLogEntry) {
currentSpan := ""
return func(entry oscommands.CmdLogEntry) {
if gui.Views.CmdLog == nil {
return
}
if entry.GetSpan() != currentSpan {
fmt.Fprintln(gui.Views.CmdLog, utils.ColoredString(entry.GetSpan(), color.FgYellow))
currentSpan = entry.GetSpan()
}
clrAttr := theme.DefaultTextColor
if !entry.GetCommandLine() {
clrAttr = color.FgMagenta
}
gui.CmdLog = append(gui.CmdLog, entry.GetCmdStr())
fmt.Fprintln(gui.Views.CmdLog, " "+utils.ColoredString(entry.GetCmdStr(), clrAttr))
}
})
}()
oSCommand.SetOnRunCommand(onRunCommand)
gui.OnRunCommand = onRunCommand
return gui, nil
}

View File

@@ -33,11 +33,11 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error {
onPress: gui.handleDeletePatchFromCommit,
},
{
displayString: "pull patch out into index",
onPress: gui.handlePullPatchIntoWorkingTree,
displayString: "move patch out into index",
onPress: gui.handleMovePatchIntoWorkingTree,
},
{
displayString: "pull patch into new commit",
displayString: "move patch into new commit",
onPress: gui.handlePullPatchIntoNewCommit,
},
}...)
@@ -98,7 +98,7 @@ func (gui *Gui) handleDeletePatchFromCommit() error {
return gui.WithWaitingStatus(gui.Tr.RebasingStatus, func() error {
commitIndex := gui.getPatchCommitIndex()
err := gui.GitCommand.DeletePatchesFromCommit(gui.State.Commits, commitIndex, gui.GitCommand.PatchManager)
err := gui.GitCommand.WithSpan("Remove patch from commit").DeletePatchesFromCommit(gui.State.Commits, commitIndex, gui.GitCommand.PatchManager)
return gui.handleGenericMergeCommandResult(err)
})
}
@@ -114,12 +114,12 @@ func (gui *Gui) handleMovePatchToSelectedCommit() error {
return gui.WithWaitingStatus(gui.Tr.RebasingStatus, func() error {
commitIndex := gui.getPatchCommitIndex()
err := gui.GitCommand.MovePatchToSelectedCommit(gui.State.Commits, commitIndex, gui.State.Panels.Commits.SelectedLineIdx, gui.GitCommand.PatchManager)
err := gui.GitCommand.WithSpan("Move patch to selected commit").MovePatchToSelectedCommit(gui.State.Commits, commitIndex, gui.State.Panels.Commits.SelectedLineIdx, gui.GitCommand.PatchManager)
return gui.handleGenericMergeCommandResult(err)
})
}
func (gui *Gui) handlePullPatchIntoWorkingTree() error {
func (gui *Gui) handleMovePatchIntoWorkingTree() error {
if ok, err := gui.validateNormalWorkingTreeState(); !ok {
return err
}
@@ -131,7 +131,7 @@ func (gui *Gui) handlePullPatchIntoWorkingTree() error {
pull := func(stash bool) error {
return gui.WithWaitingStatus(gui.Tr.RebasingStatus, func() error {
commitIndex := gui.getPatchCommitIndex()
err := gui.GitCommand.PullPatchIntoIndex(gui.State.Commits, commitIndex, gui.GitCommand.PatchManager, stash)
err := gui.GitCommand.WithSpan("Move patch into index").MovePatchIntoIndex(gui.State.Commits, commitIndex, gui.GitCommand.PatchManager, stash)
return gui.handleGenericMergeCommandResult(err)
})
}
@@ -160,7 +160,7 @@ func (gui *Gui) handlePullPatchIntoNewCommit() error {
return gui.WithWaitingStatus(gui.Tr.RebasingStatus, func() error {
commitIndex := gui.getPatchCommitIndex()
err := gui.GitCommand.PullPatchIntoNewCommit(gui.State.Commits, commitIndex, gui.GitCommand.PatchManager)
err := gui.GitCommand.WithSpan("Move patch into new commit").PullPatchIntoNewCommit(gui.State.Commits, commitIndex, gui.GitCommand.PatchManager)
return gui.handleGenericMergeCommandResult(err)
})
}
@@ -170,7 +170,11 @@ func (gui *Gui) handleApplyPatch(reverse bool) error {
return err
}
if err := gui.GitCommand.PatchManager.ApplyPatches(reverse); err != nil {
span := "Apply patch"
if reverse {
span = "Apply patch in reverse"
}
if err := gui.GitCommand.WithSpan(span).PatchManager.ApplyPatches(reverse); err != nil {
return gui.surfaceError(err)
}
return gui.refreshSidePanels(refreshOptions{mode: ASYNC})

View File

@@ -43,18 +43,20 @@ func (gui *Gui) genericMergeCommand(command string) error {
return gui.createErrorPanel(gui.Tr.NotMergingOrRebasing)
}
gitCommand := gui.GitCommand.WithSpan(fmt.Sprintf("Merge: %s", command))
commandType := strings.Replace(status, "ing", "e", 1)
// we should end up with a command like 'git merge --continue'
// 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 != "abort" && gui.Config.GetUserConfig().Git.Merging.ManualCommit {
sub := gui.OSCommand.PrepareSubProcess("git", commandType, fmt.Sprintf("--%s", command))
sub := gitCommand.OSCommand.PrepareSubProcess("git", commandType, fmt.Sprintf("--%s", command))
if sub != nil {
return gui.runSubprocessWithSuspenseAndRefresh(sub)
}
return nil
}
result := gui.GitCommand.GenericMergeOrRebaseAction(commandType, command)
result := gitCommand.GenericMergeOrRebaseAction(commandType, command)
if err := gui.handleGenericMergeCommandResult(result); err != nil {
return err
}

View File

@@ -142,7 +142,7 @@ func (gui *Gui) applySelection(reverse bool, state *lBlPanelState) error {
if !reverse || state.SecondaryFocused {
applyFlags = append(applyFlags, "cached")
}
err := gui.GitCommand.ApplyPatch(patch, applyFlags...)
err := gui.GitCommand.WithSpan("Apply patch").ApplyPatch(patch, applyFlags...)
if err != nil {
return gui.surfaceError(err)
}

View File

@@ -106,7 +106,7 @@ func (gui *Gui) stashDo(method string) error {
return gui.createErrorPanel(errorMessage)
}
if err := gui.GitCommand.StashDo(stashEntry.Index, method); err != nil {
if err := gui.GitCommand.WithSpan("Stash").StashDo(stashEntry.Index, method); err != nil {
return gui.surfaceError(err)
}
return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{STASH, FILES}})

View File

@@ -81,7 +81,7 @@ 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.SubmoduleDelete(submodule); err != nil {
if err := gui.GitCommand.WithSpan("Remove submodule").SubmoduleDelete(submodule); err != nil {
return gui.surfaceError(err)
}
@@ -107,17 +107,19 @@ func (gui *Gui) fileForSubmodule(submodule *models.SubmoduleConfig) *models.File
}
func (gui *Gui) resetSubmodule(submodule *models.SubmoduleConfig) error {
gitCommand := gui.GitCommand.WithSpan("Reset submodule")
file := gui.fileForSubmodule(submodule)
if file != nil {
if err := gui.GitCommand.UnStageFile(file.Names(), file.Tracked); err != nil {
if err := gitCommand.UnStageFile(file.Names(), file.Tracked); err != nil {
return gui.surfaceError(err)
}
}
if err := gui.GitCommand.SubmoduleStash(submodule); err != nil {
if err := gitCommand.SubmoduleStash(submodule); err != nil {
return gui.surfaceError(err)
}
if err := gui.GitCommand.SubmoduleReset(submodule); err != nil {
if err := gitCommand.SubmoduleReset(submodule); err != nil {
return gui.surfaceError(err)
}
@@ -140,7 +142,7 @@ func (gui *Gui) handleAddSubmodule() error {
initialContent: submoduleName,
handleConfirm: func(submodulePath string) error {
return gui.WithWaitingStatus(gui.Tr.LcAddingSubmoduleStatus, func() error {
err := gui.GitCommand.SubmoduleAdd(submoduleName, submodulePath, submoduleUrl)
err := gui.GitCommand.WithSpan("Add submodule").SubmoduleAdd(submoduleName, submodulePath, submoduleUrl)
gui.handleCredentialsPopup(err)
return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{SUBMODULES}})
@@ -160,7 +162,7 @@ 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.SubmoduleUpdateUrl(submodule.Name, submodule.Path, newUrl)
err := gui.GitCommand.WithSpan("Update submodule URL").SubmoduleUpdateUrl(submodule.Name, submodule.Path, newUrl)
gui.handleCredentialsPopup(err)
return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{SUBMODULES}})
@@ -171,7 +173,7 @@ 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.SubmoduleInit(submodule.Path)
err := gui.GitCommand.WithSpan("Initialise submodule").SubmoduleInit(submodule.Path)
gui.handleCredentialsPopup(err)
return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{SUBMODULES}})
@@ -214,7 +216,7 @@ func (gui *Gui) handleBulkSubmoduleActionsMenu() error {
displayStrings: []string{gui.Tr.LcBulkInitSubmodules, utils.ColoredString(gui.GitCommand.SubmoduleBulkInitCmdStr(), color.FgGreen)},
onPress: func() error {
return gui.WithWaitingStatus(gui.Tr.LcRunningCommand, func() error {
if err := gui.OSCommand.RunCommand(gui.GitCommand.SubmoduleBulkInitCmdStr()); err != nil {
if err := gui.OSCommand.WithSpan("Bulk initialise submodules").RunCommand(gui.GitCommand.SubmoduleBulkInitCmdStr()); err != nil {
return gui.surfaceError(err)
}
@@ -226,7 +228,7 @@ func (gui *Gui) handleBulkSubmoduleActionsMenu() error {
displayStrings: []string{gui.Tr.LcBulkUpdateSubmodules, utils.ColoredString(gui.GitCommand.SubmoduleBulkUpdateCmdStr(), color.FgYellow)},
onPress: func() error {
return gui.WithWaitingStatus(gui.Tr.LcRunningCommand, func() error {
if err := gui.OSCommand.RunCommand(gui.GitCommand.SubmoduleBulkUpdateCmdStr()); err != nil {
if err := gui.OSCommand.WithSpan("Bulk update submodules").RunCommand(gui.GitCommand.SubmoduleBulkUpdateCmdStr()); err != nil {
return gui.surfaceError(err)
}
@@ -238,7 +240,7 @@ func (gui *Gui) handleBulkSubmoduleActionsMenu() error {
displayStrings: []string{gui.Tr.LcSubmoduleStashAndReset, utils.ColoredString(fmt.Sprintf("git stash in each submodule && %s", gui.GitCommand.SubmoduleForceBulkUpdateCmdStr()), color.FgRed)},
onPress: func() error {
return gui.WithWaitingStatus(gui.Tr.LcRunningCommand, func() error {
if err := gui.GitCommand.ResetSubmodules(gui.State.Submodules); err != nil {
if err := gui.GitCommand.WithSpan("Bulk stash and reset submodules").ResetSubmodules(gui.State.Submodules); err != nil {
return gui.surfaceError(err)
}
@@ -250,7 +252,7 @@ func (gui *Gui) handleBulkSubmoduleActionsMenu() error {
displayStrings: []string{gui.Tr.LcBulkDeinitSubmodules, utils.ColoredString(gui.GitCommand.SubmoduleBulkDeinitCmdStr(), color.FgRed)},
onPress: func() error {
return gui.WithWaitingStatus(gui.Tr.LcRunningCommand, func() error {
if err := gui.OSCommand.RunCommand(gui.GitCommand.SubmoduleBulkDeinitCmdStr()); err != nil {
if err := gui.OSCommand.WithSpan("Bulk deinitialise submodules").RunCommand(gui.GitCommand.SubmoduleBulkDeinitCmdStr()); err != nil {
return gui.surfaceError(err)
}
@@ -265,7 +267,7 @@ func (gui *Gui) handleBulkSubmoduleActionsMenu() error {
func (gui *Gui) handleUpdateSubmodule(submodule *models.SubmoduleConfig) error {
return gui.WithWaitingStatus(gui.Tr.LcUpdatingSubmoduleStatus, func() error {
err := gui.GitCommand.SubmoduleUpdate(submodule.Path)
err := gui.GitCommand.WithSpan("Update submodule").SubmoduleUpdate(submodule.Path)
gui.handleCredentialsPopup(err)
return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{SUBMODULES}})