From 91fe68576cde3e4582373b255c5eb97cd3065c71 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Wed, 5 Jan 2022 12:01:59 +1100 Subject: refactor --- pkg/commands/oscommands/cmd_obj.go | 12 +++- pkg/commands/oscommands/cmd_obj_builder.go | 30 ++++++++-- pkg/commands/oscommands/cmd_obj_runner.go | 4 -- pkg/commands/oscommands/dummies.go | 5 +- pkg/commands/oscommands/os.go | 88 +++++++----------------------- pkg/commands/rebasing.go | 6 +- pkg/gui/branches_panel.go | 26 ++++----- pkg/gui/cherry_picking.go | 2 +- pkg/gui/command_log_panel.go | 46 ++++++++++------ pkg/gui/commit_files_panel.go | 4 +- pkg/gui/commit_message_panel.go | 3 +- pkg/gui/commits_panel.go | 61 +++++++++------------ pkg/gui/custom_commands.go | 2 +- pkg/gui/discard_changes_menu_panel.go | 8 +-- pkg/gui/files_panel.go | 48 ++++++++-------- pkg/gui/git_flow.go | 4 +- pkg/gui/global_handlers.go | 6 +- pkg/gui/gpg.go | 2 + pkg/gui/gui.go | 9 ++- pkg/gui/line_by_line_panel.go | 2 +- pkg/gui/merge_panel.go | 7 ++- pkg/gui/patch_options_panel.go | 14 ++--- pkg/gui/pull_request_menu_panel.go | 5 +- pkg/gui/rebase_options_panel.go | 2 +- pkg/gui/reflog_panel.go | 2 +- pkg/gui/remote_branches_panel.go | 4 +- pkg/gui/remotes_panel.go | 8 +-- pkg/gui/reset_menu_panel.go | 2 +- pkg/gui/staging_panel.go | 2 +- pkg/gui/stash_panel.go | 2 +- pkg/gui/sub_commits_panel.go | 2 +- pkg/gui/submodules_panel.go | 20 +++---- pkg/gui/tags_panel.go | 6 +- pkg/gui/undoing.go | 8 +-- pkg/gui/workspace_reset_options_panel.go | 12 ++-- pkg/i18n/chinese.go | 3 +- pkg/i18n/english.go | 12 ++-- 37 files changed, 226 insertions(+), 253 deletions(-) (limited to 'pkg') diff --git a/pkg/commands/oscommands/cmd_obj.go b/pkg/commands/oscommands/cmd_obj.go index 192871af0..8fb7fa313 100644 --- a/pkg/commands/oscommands/cmd_obj.go +++ b/pkg/commands/oscommands/cmd_obj.go @@ -12,6 +12,7 @@ type ICmdObj interface { // using NewFromArgs, the output won't be quite the same as what you would type // into a terminal e.g. 'sh -c git commit' as opposed to 'sh -c "git commit"' ToString() string + AddEnvVars(...string) ICmdObj GetEnvVars() []string @@ -22,9 +23,16 @@ type ICmdObj interface { // runs the command and runs a callback function on each line of the output. If the callback returns true for the boolean value, we kill the process and return. RunAndProcessLines(onLine func(line string) (bool, error)) error - // Marks the command object as readonly, so that when it is run, we don't log it to the user. - // We only want to log commands to the user which change state in some way. + // Be calling DontLog(), we're saying that once we call Run(), we don't want to + // log the command in the UI (it'll still be logged in the log file). The general rule + // is that if a command doesn't change the git state (e.g. read commands like `git diff`) + // then we don't want to log it. If we are changing something (e.g. `git add .`) then + // we do. The only exception is if we're running a command in the background periodically + // like `git fetch`, which technically does mutate stuff but isn't something we need + // to notify the user about. DontLog() ICmdObj + + // This returns false if DontLog() was called ShouldLog() bool } diff --git a/pkg/commands/oscommands/cmd_obj_builder.go b/pkg/commands/oscommands/cmd_obj_builder.go index 5929d6faf..a493ae651 100644 --- a/pkg/commands/oscommands/cmd_obj_builder.go +++ b/pkg/commands/oscommands/cmd_obj_builder.go @@ -21,9 +21,8 @@ type ICmdObjBuilder interface { } type CmdObjBuilder struct { - runner ICmdObjRunner - logCmdObj func(ICmdObj) - platform *Platform + runner ICmdObjRunner + platform *Platform } // poor man's version of explicitly saying that struct X implements interface Y @@ -76,8 +75,27 @@ func (self *CmdObjBuilder) CloneWithNewRunner(decorate func(ICmdObjRunner) ICmdO decoratedRunner := decorate(self.runner) return &CmdObjBuilder{ - runner: decoratedRunner, - logCmdObj: self.logCmdObj, - platform: self.platform, + runner: decoratedRunner, + platform: self.platform, } } + +func (self *CmdObjBuilder) Quote(message string) string { + var quote string + if self.platform.OS == "windows" { + quote = `\"` + message = strings.NewReplacer( + `"`, `"'"'"`, + `\"`, `\\"`, + ).Replace(message) + } else { + quote = `"` + message = strings.NewReplacer( + `\`, `\\`, + `"`, `\"`, + `$`, `\$`, + "`", "\\`", + ).Replace(message) + } + return quote + message + quote +} diff --git a/pkg/commands/oscommands/cmd_obj_runner.go b/pkg/commands/oscommands/cmd_obj_runner.go index 0c6bf086e..8eb6d437d 100644 --- a/pkg/commands/oscommands/cmd_obj_runner.go +++ b/pkg/commands/oscommands/cmd_obj_runner.go @@ -22,10 +22,6 @@ type cmdObjRunner struct { var _ ICmdObjRunner = &cmdObjRunner{} func (self *cmdObjRunner) Run(cmdObj ICmdObj) error { - if cmdObj.ShouldLog() { - self.logCmdObj(cmdObj) - } - _, err := self.RunWithOutput(cmdObj) return err } diff --git a/pkg/commands/oscommands/dummies.go b/pkg/commands/oscommands/dummies.go index f44cc9b72..8a97589ed 100644 --- a/pkg/commands/oscommands/dummies.go +++ b/pkg/commands/oscommands/dummies.go @@ -13,9 +13,8 @@ func NewDummyOSCommand() *OSCommand { func NewDummyCmdObjBuilder(runner ICmdObjRunner) *CmdObjBuilder { return &CmdObjBuilder{ - runner: runner, - logCmdObj: func(ICmdObj) {}, - platform: dummyPlatform, + runner: runner, + platform: dummyPlatform, } } diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index 0d2a936ef..bf1bb9ac6 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -22,11 +22,11 @@ type OSCommand struct { Platform *Platform Getenv func(string) string - // callback to run before running a command, i.e. for the purposes of logging - onRunCommand func(CmdLogEntry) - - // something like 'Staging File': allows us to group cmd logs under a single title - CmdLogSpan string + // callback to run before running a command, i.e. for the purposes of logging. + // the string argument is the command string e.g. 'git add .' and the bool is + // whether we're dealing with a command line command or something more general + // like 'Opening PR URL', or something handled by Go's standard library. + logCommandFn func(string, bool) removeFile func(string) error @@ -42,36 +42,6 @@ type Platform struct { OpenLinkCommand string } -// TODO: make these fields private -type CmdLogEntry struct { - // e.g. 'git commit -m "haha"' - cmdStr string - // Span is something like 'Staging File'. Multiple commands can be grouped under the same - // span - span string - - // sometimes our command is direct like 'git commit', and sometimes it's a - // command to remove a file but through Go's standard library rather than the - // command line - commandLine bool -} - -func (e CmdLogEntry) GetCmdStr() string { - return e.cmdStr -} - -func (e CmdLogEntry) GetSpan() string { - return e.span -} - -func (e CmdLogEntry) GetCommandLine() bool { - return e.commandLine -} - -func NewCmdLogEntry(cmdStr string, span string, commandLine bool) CmdLogEntry { - return CmdLogEntry{cmdStr: cmdStr, span: span, commandLine: commandLine} -} - // NewOSCommand os command runner func NewOSCommand(common *common.Common, platform *Platform) *OSCommand { c := &OSCommand{ @@ -82,7 +52,7 @@ func NewOSCommand(common *common.Common, platform *Platform) *OSCommand { } runner := &cmdObjRunner{log: common.Log, logCmdObj: c.LogCmdObj} - c.Cmd = &CmdObjBuilder{runner: runner, logCmdObj: c.LogCmdObj, platform: platform} + c.Cmd = &CmdObjBuilder{runner: runner, platform: platform} return c } @@ -94,13 +64,13 @@ func (c *OSCommand) LogCmdObj(cmdObj ICmdObj) { func (c *OSCommand) LogCommand(cmdStr string, commandLine bool) { c.Log.WithField("command", cmdStr).Info("RunCommand") - if c.onRunCommand != nil { - c.onRunCommand(NewCmdLogEntry(cmdStr, c.CmdLogSpan, commandLine)) + if c.logCommandFn != nil { + c.logCommandFn(cmdStr, commandLine) } } -func (c *OSCommand) SetOnRunCommand(f func(CmdLogEntry)) { - c.onRunCommand = f +func (c *OSCommand) SetLogCommandFn(f func(string, bool)) { + c.logCommandFn = f } // To be used for testing only @@ -145,26 +115,6 @@ func (c *OSCommand) Quote(message string) string { return c.Cmd.Quote(message) } -func (self *CmdObjBuilder) Quote(message string) string { - var quote string - if self.platform.OS == "windows" { - quote = `\"` - message = strings.NewReplacer( - `"`, `"'"'"`, - `\"`, `\\"`, - ).Replace(message) - } else { - quote = `"` - message = strings.NewReplacer( - `\`, `\\`, - `"`, `\"`, - `$`, `\$`, - "`", "\\`", - ).Replace(message) - } - return quote + message + quote -} - // AppendLineToFile adds a new line in file func (c *OSCommand) AppendLineToFile(filename, line string) error { c.LogCommand(fmt.Sprintf("Appending '%s' to file '%s'", line, filename), false) @@ -236,15 +186,6 @@ func (c *OSCommand) FileExists(path string) (bool, error) { return true, nil } -// GetLazygitPath returns the path of the currently executed file -func (c *OSCommand) GetLazygitPath() string { - ex, err := os.Executable() // get the executable path for git to use - if err != nil { - ex = os.Args[0] // fallback to the first call argument if needed - } - return `"` + filepath.ToSlash(ex) + `"` -} - // PipeCommands runs a heap of commands and pipes their inputs/outputs together like A | B | C func (c *OSCommand) PipeCommands(commandStrings ...string) error { cmds := make([]*exec.Cmd, len(commandStrings)) @@ -333,3 +274,12 @@ func (c *OSCommand) RemoveFile(path string) error { func GetTempDir() string { return filepath.Join(os.TempDir(), "lazygit") } + +// GetLazygitPath returns the path of the currently executed file +func GetLazygitPath() string { + ex, err := os.Executable() // get the executable path for git to use + if err != nil { + ex = os.Args[0] // fallback to the first call argument if needed + } + return `"` + filepath.ToSlash(ex) + `"` +} diff --git a/pkg/commands/rebasing.go b/pkg/commands/rebasing.go index 8827246ab..b930604ea 100644 --- a/pkg/commands/rebasing.go +++ b/pkg/commands/rebasing.go @@ -59,7 +59,7 @@ func (c *GitCommand) InteractiveRebase(commits []*models.Commit, index int, acti // we tell git to run lazygit to edit the todo list, and we pass the client // lazygit a todo string to write to the todo file func (c *GitCommand) PrepareInteractiveRebaseCommand(baseSha string, todo string, overrideEditor bool) (oscommands.ICmdObj, error) { - ex := c.OSCommand.GetLazygitPath() + ex := oscommands.GetLazygitPath() debug := "FALSE" if c.Debug { @@ -267,8 +267,8 @@ func (c *GitCommand) GenericMergeOrRebaseAction(commandType string, command stri } func (c *GitCommand) runSkipEditorCommand(command string) error { - cmdObj := c.OSCommand.Cmd.New(command) - lazyGitPath := c.OSCommand.GetLazygitPath() + cmdObj := c.Cmd.New(command) + lazyGitPath := oscommands.GetLazygitPath() return cmdObj. AddEnvVars( "LAZYGIT_CLIENT_COMMAND=EXIT_IMMEDIATELY", diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 313186256..7481104cf 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -7,7 +7,6 @@ import ( "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/utils" ) @@ -80,7 +79,7 @@ func (gui *Gui) handleBranchPress() error { return gui.createErrorPanel(gui.Tr.AlreadyCheckedOutBranch) } branch := gui.getSelectedBranch() - gui.logSpan(gui.Tr.Spans.CheckoutBranch) + gui.logAction(gui.Tr.Actions.CheckoutBranch) return gui.handleCheckoutRef(branch.Name, handleCheckoutRefOptions{}) } @@ -114,12 +113,11 @@ func (gui *Gui) handleCopyPullRequestURLPress() error { if err != nil { return gui.surfaceError(err) } + gui.logAction(gui.Tr.Actions.CopyPullRequestURL) if err := gui.GitCommand.OSCommand.CopyToClipboard(url); err != nil { return gui.surfaceError(err) } - gui.OnRunCommand(oscommands.NewCmdLogEntry(fmt.Sprintf("Copying to clipboard: '%s'", url), "Copy URL", false)) - gui.raiseToast(gui.Tr.PullRequestURLCopiedToClipboard) return nil @@ -146,7 +144,7 @@ func (gui *Gui) handleForceCheckout() error { title: title, prompt: message, handleConfirm: func() error { - gui.logSpan(gui.Tr.Spans.ForceCheckoutBranch) + gui.logAction(gui.Tr.Actions.ForceCheckoutBranch) if err := gui.GitCommand.Checkout(branch.Name, commands.CheckoutOptions{Force: true}); err != nil { _ = gui.surfaceError(err) } @@ -225,7 +223,7 @@ func (gui *Gui) handleCheckoutByName() error { title: gui.Tr.BranchName + ":", findSuggestionsFunc: gui.getRefsSuggestionsFunc(), handleConfirm: func(response string) error { - gui.logSpan("Checkout branch") + gui.logAction("Checkout branch") return gui.handleCheckoutRef(response, handleCheckoutRefOptions{ onRefNotFound: func(ref string) error { return gui.ask(askOpts{ @@ -298,7 +296,7 @@ func (gui *Gui) deleteNamedBranch(selectedBranch *models.Branch, force bool) err title: title, prompt: message, handleConfirm: func() error { - gui.logSpan(gui.Tr.Spans.DeleteBranch) + gui.logAction(gui.Tr.Actions.DeleteBranch) if err := gui.GitCommand.DeleteBranch(selectedBranch.Name, force); err != nil { errMessage := err.Error() if !force && strings.Contains(errMessage, "git branch -D ") { @@ -335,7 +333,7 @@ func (gui *Gui) mergeBranchIntoCheckedOutBranch(branchName string) error { title: gui.Tr.MergingTitle, prompt: prompt, handleConfirm: func() error { - gui.logSpan(gui.Tr.Spans.Merge) + gui.logAction(gui.Tr.Actions.Merge) err := gui.GitCommand.Merge(branchName, commands.MergeOpts{}) return gui.handleGenericMergeCommandResult(err) }, @@ -377,7 +375,7 @@ func (gui *Gui) handleRebaseOntoBranch(selectedBranchName string) error { title: gui.Tr.RebasingTitle, prompt: prompt, handleConfirm: func() error { - gui.logSpan(gui.Tr.Spans.RebaseBranch) + gui.logAction(gui.Tr.Actions.RebaseBranch) err := gui.GitCommand.RebaseBranch(selectedBranchName) return gui.handleGenericMergeCommandResult(err) }, @@ -402,7 +400,7 @@ func (gui *Gui) handleFastForward() error { return gui.surfaceError(err) } - span := gui.Tr.Spans.FastForwardBranch + action := gui.Tr.Actions.FastForwardBranch split := strings.Split(upstream, "/") remoteName := split[0] @@ -419,9 +417,9 @@ func (gui *Gui) handleFastForward() error { _ = gui.createLoaderPanel(message) if gui.State.Panels.Branches.SelectedLineIdx == 0 { - _ = gui.pullWithLock(PullFilesOptions{span: span, FastForwardOnly: true}) + _ = gui.pullWithLock(PullFilesOptions{action: action, FastForwardOnly: true}) } else { - gui.logSpan(span) + gui.logAction(action) err := gui.GitCommand.FastForward(branch.Name, remoteName, remoteBranchName, gui.promptUserForCredential) gui.handleCredentialsPopup(err) _ = gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{BRANCHES}}) @@ -450,7 +448,7 @@ func (gui *Gui) handleRenameBranch() error { title: gui.Tr.NewBranchNamePrompt + " " + branch.Name + ":", initialContent: branch.Name, handleConfirm: func(newBranchName string) error { - gui.logSpan(gui.Tr.Spans.RenameBranch) + gui.logAction(gui.Tr.Actions.RenameBranch) if err := gui.GitCommand.RenameBranch(branch.Name, newBranchName); err != nil { return gui.surfaceError(err) } @@ -519,7 +517,7 @@ func (gui *Gui) handleNewBranchOffCurrentItem() error { title: message, initialContent: prefilledName, handleConfirm: func(response string) error { - gui.logSpan(gui.Tr.Spans.CreateBranch) + gui.logAction(gui.Tr.Actions.CreateBranch) if err := gui.GitCommand.NewBranch(sanitizedBranchName(response), item.ID()); err != nil { return err } diff --git a/pkg/gui/cherry_picking.go b/pkg/gui/cherry_picking.go index 5422803cf..8faa55118 100644 --- a/pkg/gui/cherry_picking.go +++ b/pkg/gui/cherry_picking.go @@ -148,7 +148,7 @@ func (gui *Gui) HandlePasteCommits() error { prompt: gui.Tr.SureCherryPick, handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.CherryPickingStatus, func() error { - gui.logSpan(gui.Tr.Spans.CherryPick) + gui.logAction(gui.Tr.Actions.CherryPick) err := gui.GitCommand.CherryPickCommits(gui.State.Modes.CherryPicking.CherryPickedCommits) return gui.handleGenericMergeCommandResult(err) }) diff --git a/pkg/gui/command_log_panel.go b/pkg/gui/command_log_panel.go index ad13f6d85..aa46a4d18 100644 --- a/pkg/gui/command_log_panel.go +++ b/pkg/gui/command_log_panel.go @@ -6,38 +6,48 @@ import ( "strings" "time" - "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/constants" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/theme" ) -func (gui *Gui) GetOnRunCommand() func(entry oscommands.CmdLogEntry) { - return func(entry oscommands.CmdLogEntry) { - if gui.Views.Extras == nil { - return - } - - gui.Views.Extras.Autoscroll = true - - textStyle := theme.DefaultTextColor - if !entry.GetCommandLine() { - textStyle = style.FgMagenta - } - gui.CmdLog = append(gui.CmdLog, entry.GetCmdStr()) - indentedCmdStr := " " + strings.Replace(entry.GetCmdStr(), "\n", "\n ", -1) - fmt.Fprint(gui.Views.Extras, "\n"+textStyle.Sprint(indentedCmdStr)) +// our UI command log looks like this: +// Stage File +// git add -- 'filename' +// Unstage File +// git reset HEAD 'filename' +// +// The 'Stage File' and 'Unstage File' lines are actions i.e they group up a set +// of command logs (typically there's only one command under an action but there may be more). +// So we call logAction to log the 'Stage File' part and then we call logCommand to log the command itself. +// We pass logCommand to our OSCommand struct so that it can handle logging commands +// for us. +func (gui *Gui) logAction(action string) { + if gui.Views.Extras == nil { + return } + + gui.Views.Extras.Autoscroll = true + + fmt.Fprint(gui.Views.Extras, "\n"+style.FgYellow.Sprint(action)) } -func (gui *Gui) logSpan(span string) { +func (gui *Gui) logCommand(cmdStr string, commandLine bool) { if gui.Views.Extras == nil { return } gui.Views.Extras.Autoscroll = true - fmt.Fprint(gui.Views.Extras, "\n"+style.FgYellow.Sprint(span)) + textStyle := theme.DefaultTextColor + if !commandLine { + // if we're not dealing with a direct command that could be run on the command line, + // we style it differently to communicate that + textStyle = style.FgMagenta + } + gui.CmdLog = append(gui.CmdLog, cmdStr) + indentedCmdStr := " " + strings.Replace(cmdStr, "\n", "\n ", -1) + fmt.Fprint(gui.Views.Extras, "\n"+textStyle.Sprint(indentedCmdStr)) } func (gui *Gui) printCommandLogHeader() { diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index f5c24adc1..6dd894906 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -63,7 +63,7 @@ func (gui *Gui) handleCheckoutCommitFile() error { return nil } - gui.logSpan(gui.Tr.Spans.CheckoutFile) + gui.logAction(gui.Tr.Actions.CheckoutFile) if err := gui.GitCommand.CheckoutFile(gui.State.CommitFileManager.GetParent(), node.GetPath()); err != nil { return gui.surfaceError(err) } @@ -83,7 +83,7 @@ func (gui *Gui) handleDiscardOldFileChange() error { prompt: gui.Tr.DiscardFileChangesPrompt, handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.RebasingStatus, func() error { - gui.logSpan(gui.Tr.Spans.DiscardOldFileChange) + gui.logAction(gui.Tr.Actions.DiscardOldFileChange) if err := gui.GitCommand.DiscardOldFileChanges(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, fileName); err != nil { if err := gui.handleGenericMergeCommandResult(err); err != nil { return err diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go index f12d0f28f..932c1608a 100644 --- a/pkg/gui/commit_message_panel.go +++ b/pkg/gui/commit_message_panel.go @@ -5,7 +5,6 @@ import ( "strings" "github.com/jesseduffield/gocui" - "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/utils" ) @@ -25,7 +24,7 @@ func (gui *Gui) handleCommitConfirm() error { } cmdObj := gui.GitCommand.CommitCmdObj(message, strings.Join(flags, " ")) - gui.OnRunCommand(oscommands.NewCmdLogEntry(cmdObj.ToString(), gui.Tr.Spans.Commit, true)) + gui.logAction(gui.Tr.Actions.Commit) _ = gui.returnFromContext() return gui.withGpgHandling(cmdObj, gui.Tr.CommittingStatus, func() error { diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 4e67e4a05..76f81022e 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -6,7 +6,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/loaders" "github.com/jesseduffield/lazygit/pkg/commands/models" - "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/utils" ) @@ -173,7 +172,7 @@ func (gui *Gui) handleCommitSquashDown() error { prompt: gui.Tr.SureSquashThisCommit, handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.SquashingStatus, func() error { - gui.logSpan(gui.Tr.Spans.SquashCommitDown) + gui.logAction(gui.Tr.Actions.SquashCommitDown) err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "squash") return gui.handleGenericMergeCommandResult(err) }) @@ -203,7 +202,7 @@ func (gui *Gui) handleCommitFixup() error { prompt: gui.Tr.SureFixupThisCommit, handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.FixingStatus, func() error { - gui.logSpan(gui.Tr.Spans.FixupCommit) + gui.logAction(gui.Tr.Actions.FixupCommit) err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "fixup") return gui.handleGenericMergeCommandResult(err) }) @@ -242,7 +241,7 @@ func (gui *Gui) handleRenameCommit() error { title: gui.Tr.LcRenameCommit, initialContent: message, handleConfirm: func(response string) error { - gui.logSpan(gui.Tr.Spans.RewordCommit) + gui.logAction(gui.Tr.Actions.RewordCommit) if err := gui.GitCommand.RenameCommit(response); err != nil { return gui.surfaceError(err) } @@ -265,7 +264,7 @@ func (gui *Gui) handleRenameCommitEditor() error { return nil } - gui.logSpan(gui.Tr.Spans.RewordCommit) + gui.logAction(gui.Tr.Actions.RewordCommit) subProcess, err := gui.GitCommand.RewordCommit(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx) if err != nil { return gui.surfaceError(err) @@ -294,11 +293,11 @@ func (gui *Gui) handleMidRebaseCommand(action string) (bool, error) { return true, gui.createErrorPanel(gui.Tr.LcRewordNotSupported) } - gui.OnRunCommand(oscommands.NewCmdLogEntry( + gui.logAction("Update rebase TODO") + gui.logCommand( fmt.Sprintf("Updating rebase action of commit %s to '%s'", selectedCommit.ShortSha(), action), - "Update rebase TODO", false, - )) + ) if err := gui.GitCommand.EditRebaseTodo(gui.State.Panels.Commits.SelectedLineIdx, action); err != nil { return false, gui.surfaceError(err) @@ -325,7 +324,7 @@ func (gui *Gui) handleCommitDelete() error { prompt: gui.Tr.DeleteCommitPrompt, handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.DeletingStatus, func() error { - gui.logSpan(gui.Tr.Spans.DropCommit) + gui.logAction(gui.Tr.Actions.DropCommit) err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "drop") return gui.handleGenericMergeCommandResult(err) }) @@ -338,8 +337,6 @@ func (gui *Gui) handleCommitMoveDown() error { return err } - span := gui.Tr.Spans.MoveCommitDown - index := gui.State.Panels.Commits.SelectedLineIdx selectedCommit := gui.State.Commits[index] if selectedCommit.Status == "rebasing" { @@ -349,11 +346,8 @@ func (gui *Gui) handleCommitMoveDown() error { // logging directly here because MoveTodoDown doesn't have enough information // to provide a useful log - gui.OnRunCommand(oscommands.NewCmdLogEntry( - fmt.Sprintf("Moving commit %s down", selectedCommit.ShortSha()), - span, - false, - )) + gui.logAction(gui.Tr.Actions.MoveCommitDown) + gui.logCommand(fmt.Sprintf("Moving commit %s down", selectedCommit.ShortSha()), false) if err := gui.GitCommand.MoveTodoDown(index); err != nil { return gui.surfaceError(err) @@ -363,7 +357,7 @@ func (gui *Gui) handleCommitMoveDown() error { } return gui.WithWaitingStatus(gui.Tr.MovingStatus, func() error { - gui.logSpan(span) + gui.logAction(gui.Tr.Actions.MoveCommitDown) err := gui.GitCommand.MoveCommitDown(gui.State.Commits, index) if err == nil { gui.State.Panels.Commits.SelectedLineIdx++ @@ -382,17 +376,15 @@ func (gui *Gui) handleCommitMoveUp() error { return nil } - span := gui.Tr.Spans.MoveCommitUp - selectedCommit := gui.State.Commits[index] if selectedCommit.Status == "rebasing" { // logging directly here because MoveTodoDown doesn't have enough information // to provide a useful log - gui.OnRunCommand(oscommands.NewCmdLogEntry( + gui.logAction(gui.Tr.Actions.MoveCommitUp) + gui.logCommand( fmt.Sprintf("Moving commit %s up", selectedCommit.ShortSha()), - span, false, - )) + ) if err := gui.GitCommand.MoveTodoDown(index - 1); err != nil { return gui.surfaceError(err) @@ -402,7 +394,7 @@ func (gui *Gui) handleCommitMoveUp() error { } return gui.WithWaitingStatus(gui.Tr.MovingStatus, func() error { - gui.logSpan(span) + gui.logAction(gui.Tr.Actions.MoveCommitUp) err := gui.GitCommand.MoveCommitDown(gui.State.Commits, index-1) if err == nil { gui.State.Panels.Commits.SelectedLineIdx-- @@ -425,7 +417,7 @@ func (gui *Gui) handleCommitEdit() error { } return gui.WithWaitingStatus(gui.Tr.RebasingStatus, func() error { - gui.logSpan(gui.Tr.Spans.EditCommit) + gui.logAction(gui.Tr.Actions.EditCommit) err = gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "edit") return gui.handleGenericMergeCommandResult(err) }) @@ -441,7 +433,7 @@ func (gui *Gui) handleCommitAmendTo() error { prompt: gui.Tr.AmendCommitPrompt, handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.AmendingStatus, func() error { - gui.logSpan(gui.Tr.Spans.AmendCommit) + gui.logAction(gui.Tr.Actions.AmendCommit) err := gui.GitCommand.AmendTo(gui.State.Commits[gui.State.Panels.Commits.SelectedLineIdx].Sha) return gui.handleGenericMergeCommandResult(err) }) @@ -477,7 +469,7 @@ func (gui *Gui) handleCommitRevert() error { if commit.IsMerge() { return gui.createRevertMergeCommitMenu(commit) } else { - gui.logSpan(gui.Tr.Spans.RevertCommit) + gui.logAction(gui.Tr.Actions.RevertCommit) if err := gui.GitCommand.Revert(commit.Sha); err != nil { return gui.surfaceError(err) } @@ -498,7 +490,7 @@ func (gui *Gui) createRevertMergeCommitMenu(commit *models.Commit) error { displayString: fmt.Sprintf("%s: %s", utils.SafeTruncate(parentSha, 8), message), onPress: func() error { parentNumber := i + 1 - gui.logSpan(gui.Tr.Spans.RevertCommit) + gui.logAction(gui.Tr.Actions.RevertCommit) if err := gui.GitCommand.RevertMerge(commit.Sha, parentNumber); err != nil { return gui.surfaceError(err) } @@ -545,7 +537,7 @@ func (gui *Gui) handleCreateFixupCommit() error { title: gui.Tr.CreateFixupCommit, prompt: prompt, handleConfirm: func() error { - gui.logSpan(gui.Tr.Spans.CreateFixupCommit) + gui.logAction(gui.Tr.Actions.CreateFixupCommit) if err := gui.GitCommand.CreateFixupCommit(commit.Sha); err != nil { return gui.surfaceError(err) } @@ -577,7 +569,7 @@ func (gui *Gui) handleSquashAllAboveFixupCommits() error { prompt: prompt, handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.SquashingStatus, func() error { - gui.logSpan(gui.Tr.Spans.SquashAllAboveFixupCommits) + gui.logAction(gui.Tr.Actions.SquashAllAboveFixupCommits) err := gui.GitCommand.SquashAllAboveFixupCommits(commit.Sha) return gui.handleGenericMergeCommandResult(err) }) @@ -625,7 +617,7 @@ func (gui *Gui) handleCreateAnnotatedTag(commitSha string) error { return gui.prompt(promptOpts{ title: gui.Tr.TagMessageTitle, handleConfirm: func(msg string) error { - gui.logSpan(gui.Tr.Spans.CreateAnnotatedTag) + gui.logAction(gui.Tr.Actions.CreateAnnotatedTag) if err := gui.GitCommand.CreateAnnotatedTag(tagName, commitSha, msg); err != nil { return gui.surfaceError(err) } @@ -640,7 +632,7 @@ func (gui *Gui) handleCreateLightweightTag(commitSha string) error { return gui.prompt(promptOpts{ title: gui.Tr.TagNameTitle, handleConfirm: func(tagName string) error { - gui.logSpan(gui.Tr.Spans.CreateLightweightTag) + gui.logAction(gui.Tr.Actions.CreateLightweightTag) if err := gui.GitCommand.CreateLightweightTag(tagName, commitSha); err != nil { return gui.surfaceError(err) } @@ -659,7 +651,7 @@ func (gui *Gui) handleCheckoutCommit() error { title: gui.Tr.LcCheckoutCommit, prompt: gui.Tr.SureCheckoutThisCommit, handleConfirm: func() error { - gui.logSpan(gui.Tr.Spans.CheckoutCommit) + gui.logAction(gui.Tr.Actions.CheckoutCommit) return gui.handleCheckoutRef(commit.Sha, handleCheckoutRefOptions{}) }, }) @@ -715,7 +707,7 @@ func (gui *Gui) handleCopySelectedCommitMessageToClipboard() error { return gui.surfaceError(err) } - gui.logSpan(gui.Tr.Spans.CopyCommitMessageToClipboard) + gui.logAction(gui.Tr.Actions.CopyCommitMessageToClipboard) if err := gui.OSCommand.CopyToClipboard(message); err != nil { return gui.surfaceError(err) } @@ -826,7 +818,8 @@ func (gui *Gui) handleOpenCommitInBrowser() error { return gui.surfaceError(err) } - gui.OnRunCommand(oscommands.NewCmdLogEntry(fmt.Sprintf(gui.Tr.OpeningCommitInBrowser, url), gui.Tr.CreatePullRequest, false)) + gui.logAction(gui.Tr.CreatePullRequest) + gui.logCommand(fmt.Sprintf(gui.Tr.OpeningCommitInBrowser, url), false) return nil } diff --git a/pkg/gui/custom_commands.go b/pkg/gui/custom_commands.go index 10b6f216d..cc64be4a2 100644 --- a/pkg/gui/custom_commands.go +++ b/pkg/gui/custom_commands.go @@ -252,7 +252,7 @@ func (gui *Gui) handleCustomCommandKeybinding(customCommand config.CustomCommand loadingText = gui.Tr.LcRunningCustomCommandStatus } return gui.WithWaitingStatus(loadingText, func() error { - gui.logSpan(gui.Tr.Spans.CustomCommand) + gui.logAction(gui.Tr.Actions.CustomCommand) err := gui.OSCommand.Cmd.NewShell(cmdStr).Run() if err != nil { return gui.surfaceError(err) diff --git a/pkg/gui/discard_changes_menu_panel.go b/pkg/gui/discard_changes_menu_panel.go index 06add1238..4ed32b2f5 100644 --- a/pkg/gui/discard_changes_menu_panel.go +++ b/pkg/gui/discard_changes_menu_panel.go @@ -12,7 +12,7 @@ func (gui *Gui) handleCreateDiscardMenu() error { { displayString: gui.Tr.LcDiscardAllChanges, onPress: func() error { - gui.logSpan(gui.Tr.Spans.DiscardAllChangesInDirectory) + gui.logAction(gui.Tr.Actions.DiscardAllChangesInDirectory) if err := gui.GitCommand.DiscardAllDirChanges(node); err != nil { return gui.surfaceError(err) } @@ -25,7 +25,7 @@ func (gui *Gui) handleCreateDiscardMenu() error { menuItems = append(menuItems, &menuItem{ displayString: gui.Tr.LcDiscardUnstagedChanges, onPress: func() error { - gui.logSpan(gui.Tr.Spans.DiscardUnstagedChangesInDirectory) + gui.logAction(gui.Tr.Actions.DiscardUnstagedChangesInDirectory) if err := gui.GitCommand.DiscardUnstagedDirChanges(node); err != nil { return gui.surfaceError(err) } @@ -54,7 +54,7 @@ func (gui *Gui) handleCreateDiscardMenu() error { { displayString: gui.Tr.LcDiscardAllChanges, onPress: func() error { - gui.logSpan(gui.Tr.Spans.DiscardAllChangesInFile) + gui.logAction(gui.Tr.Actions.DiscardAllChangesInFile) if err := gui.GitCommand.DiscardAllFileChanges(file); err != nil { return gui.surfaceError(err) } @@ -67,7 +67,7 @@ func (gui *Gui) handleCreateDiscardMenu() error { menuItems = append(menuItems, &menuItem{ displayString: gui.Tr.LcDiscardUnstagedChanges, onPress: func() error { - gui.logSpan(gui.Tr.Spans.DiscardAllUnstagedChangesInFile) + gui.logAction(gui.Tr.Actions.DiscardAllUnstagedChangesInFile) if err := gui.GitCommand.DiscardUnstagedFileChanges(file); err != nil { return gui.surfaceError(err) } diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 483aa57a5..094060032 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -9,7 +9,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands/loaders" "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" @@ -207,12 +206,12 @@ func (gui *Gui) handleFilePress() error { } if file.HasUnstagedChanges { - gui.logSpan(gui.Tr.Spans.StageFile) + gui.logAction(gui.Tr.Actions.StageFile) if err := gui.GitCommand.StageFile(file.Name); err != nil { return gui.surfaceError(err) } } else { - gui.logSpan(gui.Tr.Spans.UnstageFile) + gui.logAction(gui.Tr.Actions.UnstageFile) if err := gui.GitCommand.UnStageFile(file.Names(), file.Tracked); err != nil { return gui.surfaceError(err) } @@ -225,13 +224,13 @@ func (gui *Gui) handleFilePress() error { } if node.GetHasUnstagedChanges() { - gui.logSpan(gui.Tr.Spans.StageFile) + gui.logAction(gui.Tr.Actions.StageFile) if err := gui.GitCommand.StageFile(node.Path); err != nil { return gui.surfaceError(err) } } else { // pretty sure it doesn't matter that we're always passing true here - gui.logSpan(gui.Tr.Spans.UnstageFile) + gui.logAction(gui.Tr.Actions.UnstageFile) if err := gui.GitCommand.UnStageFile([]string{node.Path}, true); err != nil { return gui.surfaceError(err) } @@ -262,10 +261,10 @@ func (gui *Gui) onFocusFile() error { func (gui *Gui) handleStageAll() error { var err error if gui.allFilesStaged() { - gui.logSpan(gui.Tr.Spans.UnstageAllFiles) + gui.logAction(gui.Tr.Actions.UnstageAllFiles) err = gui.GitCommand.UnstageAll() } else { - gui.logSpan(gui.Tr.Spans.StageAllFiles) + gui.logAction(gui.Tr.Actions.StageAllFiles) err = gui.GitCommand.StageAll() } if err != nil { @@ -289,7 +288,7 @@ func (gui *Gui) handleIgnoreFile() error { return gui.createErrorPanel("Cannot ignore .gitignore") } - gui.logSpan(gui.Tr.Spans.IgnoreFile) + gui.logAction(gui.Tr.Actions.IgnoreFile) unstageFiles := func() error { return node.ForEachFile(func(file *models.File) error { @@ -362,7 +361,7 @@ func (gui *Gui) commitPrefixConfigForRepo() *config.CommitPrefixConfig { func (gui *Gui) prepareFilesForCommit() error { noStagedFiles := len(gui.stagedFiles()) == 0 if noStagedFiles && gui.UserConfig.Gui.SkipNoStagedFilesWarning { - gui.logSpan(gui.Tr.Spans.StageAllFiles) + gui.logAction(gui.Tr.Actions.StageAllFiles) err := gui.GitCommand.StageAll() if err != nil { return err @@ -417,7 +416,7 @@ func (gui *Gui) promptToStageAllAndRetry(retry func() error) error { title: gui.Tr.NoFilesStagedTitle, prompt: gui.Tr.NoFilesStagedPrompt, handleConfirm: func() error { - gui.logSpan(gui.Tr.Spans.StageAllFiles) + gui.logAction(gui.Tr.Actions.StageAllFiles) if err := gui.GitCommand.StageAll(); err != nil { return gui.surfaceError(err) } @@ -448,7 +447,7 @@ func (gui *Gui) handleAmendCommitPress() error { prompt: gui.Tr.SureToAmend, handleConfirm: func() error { cmdObj := gui.GitCommand.AmendHeadCmdObj() - gui.OnRunCommand(oscommands.NewCmdLogEntry(cmdObj.ToString(), gui.Tr.Spans.AmendCommit, true)) + gui.logAction(gui.Tr.Actions.AmendCommit) return gui.withGpgHandling(cmdObj, gui.Tr.AmendingStatus, nil) }, }) @@ -473,7 +472,7 @@ func (gui *Gui) handleCommitEditorPress() error { cmdStr := "git " + strings.Join(args, " ") - gui.logSpan(gui.Tr.Spans.Commit) + gui.logAction(gui.Tr.Actions.Commit) return gui.runSubprocessWithSuspenseAndRefresh( gui.GitCommand.Cmd.New(cmdStr), ) @@ -520,7 +519,7 @@ func (gui *Gui) editFileAtLine(filename string, lineNumber int) error { return gui.surfaceError(err) } - gui.logSpan(gui.Tr.Spans.EditFile) + gui.logAction(gui.Tr.Actions.EditFile) return gui.runSubprocessWithSuspenseAndRefresh( gui.OSCommand.Cmd.NewShell(cmdStr), ) @@ -652,7 +651,7 @@ func (gui *Gui) handlePullFiles() error { return nil } - span := gui.Tr.Spans.Pull + action := gui.Tr.Actions.Pull currentBranch := gui.currentBranch() if currentBranch == nil { @@ -669,7 +668,7 @@ func (gui *Gui) handlePullFiles() error { } for branchName, branch := range conf.Branches { if branchName == currentBranch.Name { - return gui.pullFiles(PullFilesOptions{RemoteName: branch.Remote, BranchName: branch.Name, span: span}) + return gui.pullFiles(PullFilesOptions{RemoteName: branch.Remote, BranchName: branch.Name, action: action}) } } @@ -687,19 +686,19 @@ func (gui *Gui) handlePullFiles() error { } return gui.createErrorPanel(errorMessage) } - return gui.pullFiles(PullFilesOptions{span: span}) + return gui.pullFiles(PullFilesOptions{action: action}) }, }) } - return gui.pullFiles(PullFilesOptions{span: span}) + return gui.pullFiles(PullFilesOptions{action: action}) } type PullFilesOptions struct { RemoteName string BranchName string FastForwardOnly bool - span string + action string } func (gui *Gui) pullFiles(opts PullFilesOptions) error { @@ -717,7 +716,7 @@ func (gui *Gui) pullWithLock(opts PullFilesOptions) error { gui.Mutexes.FetchMutex.Lock() defer gui.Mutexes.FetchMutex.Unlock() - gui.logSpan(opts.span) + gui.logAction(opts.action) err := gui.GitCommand.Pull( commands.PullOptions{ @@ -745,7 +744,7 @@ func (gui *Gui) push(opts pushOpts) error { return err } go utils.Safe(func() { - gui.logSpan(gui.Tr.Spans.Push) + gui.logAction(gui.Tr.Actions.Push) err := gui.GitCommand.Push(commands.PushOpts{ Force: opts.force, UpstreamRemote: opts.upstreamRemote, @@ -902,7 +901,7 @@ func (gui *Gui) handleSwitchToMerge() error { } func (gui *Gui) openFile(filename string) error { - gui.logSpan(gui.Tr.Spans.OpenFile) + gui.logAction(gui.Tr.Actions.OpenFile) if err := gui.OSCommand.OpenFile(filename); err != nil { return gui.surfaceError(err) } @@ -935,7 +934,7 @@ func (gui *Gui) handleCustomCommand() error { gui.Log.Error(err) } - gui.OnRunCommand(oscommands.NewCmdLogEntry(command, gui.Tr.Spans.CustomCommand, true)) + gui.logAction(gui.Tr.Actions.CustomCommand) return gui.runSubprocessWithSuspenseAndRefresh( gui.OSCommand.Cmd.NewShell(command), ) @@ -948,14 +947,14 @@ func (gui *Gui) handleCreateStashMenu() error { { displayString: gui.Tr.LcStashAllChanges, onPress: func() error { - gui.logSpan(gui.Tr.Spans.StashAllChanges) + gui.logAction(gui.Tr.Actions.StashAllChanges) return gui.handleStashSave(gui.GitCommand.StashSave) }, }, { displayString: gui.Tr.LcStashStagedChanges, onPress: func() error { - gui.logSpan(gui.Tr.Spans.StashStagedChanges) + gui.logAction(gui.Tr.Actions.StashStagedChanges) return gui.handleStashSave(gui.GitCommand.StashSaveStagedChanges) }, }, @@ -1019,6 +1018,7 @@ func (gui *Gui) handleOpenMergeTool() error { title: gui.Tr.MergeToolTitle, prompt: gui.Tr.MergeToolPrompt, handleConfirm: func() error { + gui.logAction(gui.Tr.Actions.OpenMergeTool) return gui.runSubprocessWithSuspenseAndRefresh( gui.GitCommand.OpenMergeToolCmdObj(), ) diff --git a/pkg/gui/git_flow.go b/pkg/gui/git_flow.go index abf65fd59..61acffbb0 100644 --- a/pkg/gui/git_flow.go +++ b/pkg/gui/git_flow.go @@ -31,7 +31,7 @@ func (gui *Gui) gitFlowFinishBranch(gitFlowConfig string, branchName string) err return gui.createErrorPanel(gui.Tr.NotAGitFlowBranch) } - gui.logSpan(gui.Tr.Spans.GitFlowFinish) + gui.logAction(gui.Tr.Actions.GitFlowFinish) return gui.runSubprocessWithSuspenseAndRefresh( gui.GitCommand.Cmd.New("git flow " + branchType + " finish " + suffix), ) @@ -56,7 +56,7 @@ func (gui *Gui) handleCreateGitFlowMenu() error { return gui.prompt(promptOpts{ title: title, handleConfirm: func(name string) error { - gui.logSpan(gui.Tr.Spans.GitFlowStart) + gui.logAction(gui.Tr.Actions.GitFlowStart) return gui.runSubprocessWithSuspenseAndRefresh( gui.GitCommand.Cmd.New("git flow " + branchType + " start " + name), ) diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go index e1b6cfc8b..8b437e6e0 100644 --- a/pkg/gui/global_handlers.go +++ b/pkg/gui/global_handlers.go @@ -210,13 +210,13 @@ func (gui *Gui) handleMouseDownSecondary() error { return nil } -func (gui *Gui) fetch(canPromptForCredentials bool, span string) (err error) { +func (gui *Gui) fetch(canPromptForCredentials bool, action string) (err error) { gui.Mutexes.FetchMutex.Lock() defer gui.Mutexes.FetchMutex.Unlock() fetchOpts := commands.FetchOptions{} if canPromptForCredentials { - gui.logSpan(span) + gui.logAction(action) fetchOpts.PromptUserForCredential = gui.promptUserForCredential } @@ -239,7 +239,7 @@ func (gui *Gui) handleCopySelectedSideContextItemToClipboard() error { return nil } - gui.logSpan(gui.Tr.Spans.CopyToClipboard) + gui.logAction(gui.Tr.Actions.CopyToClipboard) if err := gui.OSCommand.CopyToClipboard(itemId); err != nil { return gui.surfaceError(err) } diff --git a/pkg/gui/gpg.go b/pkg/gui/gpg.go index fe40f8cb8..87d0f2971 100644 --- a/pkg/gui/gpg.go +++ b/pkg/gui/gpg.go @@ -13,6 +13,8 @@ import ( // we don't need to see a loading status if we're in a subprocess. // TODO: work out if we actually need to use a shell command here func (gui *Gui) withGpgHandling(cmdObj oscommands.ICmdObj, waitingStatus string, onSuccess func() error) error { + gui.logCommand(cmdObj.ToString(), true) + useSubprocess := gui.GitCommand.UsingGpg() if useSubprocess { success, err := gui.runSubprocessWithSuspense(gui.OSCommand.Cmd.NewShell(cmdObj.ToString())) diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 6ee63e34c..456a62a6c 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -111,8 +111,7 @@ type Gui struct { PauseBackgroundThreads bool // Log of the commands that get run, to be displayed to the user. - CmdLog []string - OnRunCommand func(entry oscommands.CmdLogEntry) + CmdLog []string // the extras window contains things like the command log ShowExtrasWindow bool @@ -457,9 +456,7 @@ func NewGui(cmn *common.Common, gitCommand *commands.GitCommand, oSCommand *osco gui.watchFilesForChanges() - onRunCommand := gui.GetOnRunCommand() - oSCommand.SetOnRunCommand(onRunCommand) - gui.OnRunCommand = onRunCommand + oSCommand.SetLogCommandFn(gui.logCommand) gui.PopupHandler = &RealPopupHandler{gui: gui} authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors) @@ -625,6 +622,8 @@ func (gui *Gui) runSubprocessWithSuspense(subprocess oscommands.ICmdObj) (bool, } func (gui *Gui) runSubprocess(cmdObj oscommands.ICmdObj) error { + gui.logCommand(cmdObj.ToString(), true) + subprocess := cmdObj.GetCmd() subprocess.Stdout = os.Stdout subprocess.Stderr = os.Stdout diff --git a/pkg/gui/line_by_line_panel.go b/pkg/gui/line_by_line_panel.go index d5e41bf1c..721af3261 100644 --- a/pkg/gui/line_by_line_panel.go +++ b/pkg/gui/line_by_line_panel.go @@ -90,7 +90,7 @@ func (gui *Gui) copySelectedToClipboard() error { return gui.withLBLActiveCheck(func(state *LblPanelState) error { selected := state.PlainRenderSelected() - gui.logSpan(gui.Tr.Spans.CopySelectedTextToClipboard) + gui.logAction(gui.Tr.Actions.CopySelectedTextToClipboard) if err := gui.OSCommand.CopyToClipboard(selected); err != nil { return gui.surfaceError(err) } diff --git a/pkg/gui/merge_panel.go b/pkg/gui/merge_panel.go index 5afbd64b2..65678797b 100644 --- a/pkg/gui/merge_panel.go +++ b/pkg/gui/merge_panel.go @@ -9,7 +9,6 @@ import ( "github.com/go-errors/errors" "github.com/jesseduffield/gocui" - "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/commands/types/enums" "github.com/jesseduffield/lazygit/pkg/gui/mergeconflicts" ) @@ -65,7 +64,8 @@ func (gui *Gui) handlePopFileSnapshot() error { if gitFile == nil { return nil } - gui.OnRunCommand(oscommands.NewCmdLogEntry("Undoing last conflict resolution", "Undo merge conflict resolution", false)) + gui.logAction("Restoring file to previous state") + gui.logCommand("Undoing last conflict resolution", false) if err := ioutil.WriteFile(gitFile.Name, []byte(prevContent), 0644); err != nil { return err } @@ -142,7 +142,8 @@ func (gui *Gui) resolveConflict(selection mergeconflicts.Selection) (bool, error case mergeconflicts.ALL: logStr = "Picking all hunks" } - gui.OnRunCommand(oscommands.NewCmdLogEntry(logStr, "Resolve merge conflict", false)) + gui.logAction("Resolve merge conflict") + gui.logCommand(logStr, false) return true, ioutil.WriteFile(gitFile.Name, []byte(output), 0644) } diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go index dd29f9d42..841683c06 100644 --- a/pkg/gui/patch_options_panel.go +++ b/pkg/gui/patch_options_panel.go @@ -98,7 +98,7 @@ func (gui *Gui) handleDeletePatchFromCommit() error { return gui.WithWaitingStatus(gui.Tr.RebasingStatus, func() error { commitIndex := gui.getPatchCommitIndex() - gui.logSpan(gui.Tr.Spans.RemovePatchFromCommit) + gui.logAction(gui.Tr.Actions.RemovePatchFromCommit) err := gui.GitCommand.DeletePatchesFromCommit(gui.State.Commits, commitIndex, gui.GitCommand.PatchManager) return gui.handleGenericMergeCommandResult(err) }) @@ -115,7 +115,7 @@ func (gui *Gui) handleMovePatchToSelectedCommit() error { return gui.WithWaitingStatus(gui.Tr.RebasingStatus, func() error { commitIndex := gui.getPatchCommitIndex() - gui.logSpan(gui.Tr.Spans.MovePatchToSelectedCommit) + gui.logAction(gui.Tr.Actions.MovePatchToSelectedCommit) err := gui.GitCommand.MovePatchToSelectedCommit(gui.State.Commits, commitIndex, gui.State.Panels.Commits.SelectedLineIdx, gui.GitCommand.PatchManager) return gui.handleGenericMergeCommandResult(err) }) @@ -133,7 +133,7 @@ func (gui *Gui) handleMovePatchIntoWorkingTree() error { pull := func(stash bool) error { return gui.WithWaitingStatus(gui.Tr.RebasingStatus, func() error { commitIndex := gui.getPatchCommitIndex() - gui.logSpan(gui.Tr.Spans.MovePatchIntoIndex) + gui.logAction(gui.Tr.Actions.MovePatchIntoIndex) err := gui.GitCommand.MovePatchIntoIndex(gui.State.Commits, commitIndex, gui.GitCommand.PatchManager, stash) return gui.handleGenericMergeCommandResult(err) }) @@ -163,7 +163,7 @@ func (gui *Gui) handlePullPatchIntoNewCommit() error { return gui.WithWaitingStatus(gui.Tr.RebasingStatus, func() error { commitIndex := gui.getPatchCommitIndex() - gui.logSpan(gui.Tr.Spans.MovePatchIntoNewCommit) + gui.logAction(gui.Tr.Actions.MovePatchIntoNewCommit) err := gui.GitCommand.PullPatchIntoNewCommit(gui.State.Commits, commitIndex, gui.GitCommand.PatchManager) return gui.handleGenericMergeCommandResult(err) }) @@ -174,11 +174,11 @@ func (gui *Gui) handleApplyPatch(reverse bool) error { return err } - span := gui.Tr.Spans.ApplyPatch + action := gui.Tr.Actions.ApplyPatch if reverse { - span = "Apply patch in reverse" + action = "Apply patch in reverse" } - gui.logSpan(span) + gui.logAction(action) if err := gui.GitCommand.PatchManager.ApplyPatches(reverse); err != nil { return gui.surfaceError(err) } diff --git a/pkg/gui/pull_request_menu_panel.go b/pkg/gui/pull_request_menu_panel.go index bf262cf5c..efc72dc46 100644 --- a/pkg/gui/pull_request_menu_panel.go +++ b/pkg/gui/pull_request_menu_panel.go @@ -5,7 +5,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/hosting_service" "github.com/jesseduffield/lazygit/pkg/commands/models" - "github.com/jesseduffield/lazygit/pkg/commands/oscommands" ) func (gui *Gui) createPullRequestMenu(selectedBranch *models.Branch, checkedOutBranch *models.Branch) error { @@ -62,12 +61,12 @@ func (gui *Gui) createPullRequest(from string, to string) error { return gui.surfaceError(err) } + gui.logAction(gui.Tr.CreatePullRequest) + if err := gui.GitCommand.OSCommand.OpenLink(url); err != nil { return gui.surfaceError(err) } - gui.OnRunCommand(oscommands.NewCmdLogEntry(fmt.Sprintf(gui.Tr.CreatingPullRequestAtUrl, url), gui.Tr.CreatePullRequest, false)) - return nil } diff --git a/pkg/gui/rebase_options_panel.go b/pkg/gui/rebase_options_panel.go index f5d4cdf94..18a50ae8c 100644 --- a/pkg/gui/rebase_options_panel.go +++ b/pkg/gui/rebase_options_panel.go @@ -51,7 +51,7 @@ func (gui *Gui) genericMergeCommand(command string) error { return gui.createErrorPanel(gui.Tr.NotMergingOrRebasing) } - gui.logSpan(fmt.Sprintf("Merge/Rebase: %s", command)) + gui.logAction(fmt.Sprintf("Merge/Rebase: %s", command)) commandType := "" switch status { diff --git a/pkg/gui/reflog_panel.go b/pkg/gui/reflog_panel.go index fcc128ae1..388bab230 100644 --- a/pkg/gui/reflog_panel.go +++ b/pkg/gui/reflog_panel.go @@ -93,7 +93,7 @@ func (gui *Gui) handleCheckoutReflogCommit() error { title: gui.Tr.LcCheckoutCommit, prompt: gui.Tr.SureCheckoutThisCommit, handleConfirm: func() error { - gui.logSpan(gui.Tr.Spans.CheckoutReflogCommit) + gui.logAction(gui.Tr.Actions.CheckoutReflogCommit) return gui.handleCheckoutRef(commit.Sha, handleCheckoutRefOptions{}) }, }) diff --git a/pkg/gui/remote_branches_panel.go b/pkg/gui/remote_branches_panel.go index 2af33bf72..d9e03b8a0 100644 --- a/pkg/gui/remote_branches_panel.go +++ b/pkg/gui/remote_branches_panel.go @@ -57,7 +57,7 @@ func (gui *Gui) handleDeleteRemoteBranch() error { prompt: message, handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.DeletingStatus, func() error { - gui.logSpan(gui.Tr.Spans.DeleteRemoteBranch) + gui.logAction(gui.Tr.Actions.DeleteRemoteBranch) err := gui.GitCommand.DeleteRemoteBranch(remoteBranch.RemoteName, remoteBranch.Name, gui.promptUserForCredential) gui.handleCredentialsPopup(err) @@ -88,7 +88,7 @@ func (gui *Gui) handleSetBranchUpstream() error { title: gui.Tr.SetUpstreamTitle, prompt: message, handleConfirm: func() error { - gui.logSpan(gui.Tr.Spans.SetBranchUpstream) + gui.logAction(gui.Tr.Actions.SetBranchUpstream) if err := gui.GitCommand.SetBranchUpstream(selectedBranch.RemoteName, selectedBranch.Name, checkedOutBranch.Name); err != nil { return gui.surfaceError(err) } diff --git a/pkg/gui/remotes_panel.go b/pkg/gui/remotes_panel.go index 721e0f61f..c0400ec35 100644 --- a/pkg/gui/remotes_panel.go +++ b/pkg/gui/remotes_panel.go @@ -85,7 +85,7 @@ func (gui *Gui) handleAddRemote() error { return gui.prompt(promptOpts{ title: gui.Tr.LcNewRemoteUrl, handleConfirm: func(remoteUrl string) error { - gui.logSpan(gui.Tr.Spans.AddRemote) + gui.logAction(gui.Tr.Actions.AddRemote) if err := gui.GitCommand.AddRemote(remoteName, remoteUrl); err != nil { return err } @@ -107,7 +107,7 @@ func (gui *Gui) handleRemoveRemote() error { title: gui.Tr.LcRemoveRemote, prompt: gui.Tr.LcRemoveRemotePrompt + " '" + remote.Name + "'?", handleConfirm: func() error { - gui.logSpan(gui.Tr.Spans.RemoveRemote) + gui.logAction(gui.Tr.Actions.RemoveRemote) if err := gui.GitCommand.RemoveRemote(remote.Name); err != nil { return gui.surfaceError(err) } @@ -135,7 +135,7 @@ func (gui *Gui) handleEditRemote() error { initialContent: remote.Name, handleConfirm: func(updatedRemoteName string) error { if updatedRemoteName != remote.Name { - gui.logSpan(gui.Tr.Spans.UpdateRemote) + gui.logAction(gui.Tr.Actions.UpdateRemote) if err := gui.GitCommand.RenameRemote(remote.Name, updatedRemoteName); err != nil { return gui.surfaceError(err) } @@ -158,7 +158,7 @@ func (gui *Gui) handleEditRemote() error { title: editUrlMessage, initialContent: url, handleConfirm: func(updatedRemoteUrl string) error { - gui.logSpan(gui.Tr.Spans.UpdateRemote) + gui.logAction(gui.Tr.Actions.UpdateRemote) if err := gui.GitCommand.UpdateRemoteUrl(updatedRemoteName, updatedRemoteUrl); err != nil { return gui.surfaceError(err) } diff --git a/pkg/gui/reset_menu_panel.go b/pkg/gui/reset_menu_panel.go index 5b138ffa7..2fa04b98b 100644 --- a/pkg/gui/reset_menu_panel.go +++ b/pkg/gui/reset_menu_panel.go @@ -38,7 +38,7 @@ func (gui *Gui) createResetMenu(ref string) error { style.FgRed.Sprintf("reset --%s %s", strength, ref), }, onPress: func() error { - gui.logSpan("Reset") + gui.logAction("Reset") return gui.resetToRef(ref, strength, []string{}) }, } diff --git a/pkg/gui/staging_panel.go b/pkg/gui/staging_panel.go index c7386832e..ed610ed55 100644 --- a/pkg/gui/staging_panel.go +++ b/pkg/gui/staging_panel.go @@ -143,7 +143,7 @@ func (gui *Gui) applySelection(reverse bool, state *LblPanelState) error { if !reverse || state.SecondaryFocused { applyFlags = append(applyFlags, "cached") } - gui.logSpan(gui.Tr.Spans.ApplyPatch) + gui.logAction(gui.Tr.Actions.ApplyPatch) err := gui.GitCommand.ApplyPatch(patch, applyFlags...) if err != nil { return gui.surfaceError(err) diff --git a/pkg/gui/stash_panel.go b/pkg/gui/stash_panel.go index a1ae78ecd..b77dd95f6 100644 --- a/pkg/gui/stash_panel.go +++ b/pkg/gui/stash_panel.go @@ -106,7 +106,7 @@ func (gui *Gui) stashDo(method string) error { return gui.createErrorPanel(errorMessage) } - gui.logSpan(gui.Tr.Spans.Stash) + gui.logAction(gui.Tr.Actions.Stash) if err := gui.GitCommand.StashDo(stashEntry.Index, method); err != nil { return gui.surfaceError(err) } diff --git a/pkg/gui/sub_commits_panel.go b/pkg/gui/sub_commits_panel.go index f6a717478..549004133 100644 --- a/pkg/gui/sub_commits_panel.go +++ b/pkg/gui/sub_commits_panel.go @@ -46,7 +46,7 @@ func (gui *Gui) handleCheckoutSubCommit() error { title: gui.Tr.LcCheckoutCommit, prompt: gui.Tr.SureCheckoutThisCommit, handleConfirm: func() error { - gui.logSpan(gui.Tr.Spans.CheckoutCommit) + gui.logAction(gui.Tr.Actions.CheckoutCommit) return gui.handleCheckoutRef(commit.Sha, handleCheckoutRefOptions{}) }, }) diff --git a/pkg/gui/submodules_panel.go b/pkg/gui/submodules_panel.go index 67af6350e..a55c7acd0 100644 --- a/pkg/gui/submodules_panel.go +++ b/pkg/gui/submodules_panel.go @@ -79,7 +79,7 @@ func (gui *Gui) removeSubmodule(submodule *models.SubmoduleConfig) error { title: gui.Tr.RemoveSubmodule, prompt: fmt.Sprintf(gui.Tr.RemoveSubmodulePrompt, submodule.Name), handleConfirm: func() error { - gui.logSpan(gui.Tr.Spans.RemoveSubmodule) + gui.logAction(gui.Tr.Actions.RemoveSubmodule) if err := gui.GitCommand.SubmoduleDelete(submodule); err != nil { return gui.surfaceError(err) } @@ -106,7 +106,7 @@ func (gui *Gui) fileForSubmodule(submodule *models.SubmoduleConfig) *models.File } func (gui *Gui) resetSubmodule(submodule *models.SubmoduleConfig) error { - gui.logSpan(gui.Tr.Spans.ResetSubmodule) + gui.logAction(gui.Tr.Actions.ResetSubmodule) file := gui.fileForSubmodule(submodule) if file != nil { @@ -141,7 +141,7 @@ func (gui *Gui) handleAddSubmodule() error { initialContent: submoduleName, handleConfirm: func(submodulePath string) error { return gui.WithWaitingStatus(gui.Tr.LcAddingSubmoduleStatus, func() error { - gui.logSpan(gui.Tr.Spans.AddSubmodule) + gui.logAction(gui.Tr.Actions.AddSubmodule) err := gui.GitCommand.SubmoduleAdd(submoduleName, submodulePath, submoduleUrl) gui.handleCredentialsPopup(err) @@ -162,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 { - gui.logSpan(gui.Tr.Spans.UpdateSubmoduleUrl) + gui.logAction(gui.Tr.Actions.UpdateSubmoduleUrl) err := gui.GitCommand.SubmoduleUpdateUrl(submodule.Name, submodule.Path, newUrl) gui.handleCredentialsPopup(err) @@ -174,7 +174,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 { - gui.logSpan(gui.Tr.Spans.InitialiseSubmodule) + gui.logAction(gui.Tr.Actions.InitialiseSubmodule) err := gui.GitCommand.SubmoduleInit(submodule.Path) gui.handleCredentialsPopup(err) @@ -218,7 +218,7 @@ 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 { - gui.logSpan(gui.Tr.Spans.BulkInitialiseSubmodules) + gui.logAction(gui.Tr.Actions.BulkInitialiseSubmodules) err := gui.GitCommand.SubmoduleBulkInitCmdObj().Run() if err != nil { return gui.surfaceError(err) @@ -232,7 +232,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 { - gui.logSpan(gui.Tr.Spans.BulkUpdateSubmodules) + gui.logAction(gui.Tr.Actions.BulkUpdateSubmodules) if err := gui.GitCommand.SubmoduleBulkUpdateCmdObj().Run(); err != nil { return gui.surfaceError(err) } @@ -245,7 +245,7 @@ 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 { - gui.logSpan(gui.Tr.Spans.BulkStashAndResetSubmodules) + gui.logAction(gui.Tr.Actions.BulkStashAndResetSubmodules) if err := gui.GitCommand.ResetSubmodules(gui.State.Submodules); err != nil { return gui.surfaceError(err) } @@ -258,7 +258,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 { - gui.logSpan(gui.Tr.Spans.BulkDeinitialiseSubmodules) + gui.logAction(gui.Tr.Actions.BulkDeinitialiseSubmodules) if err := gui.GitCommand.SubmoduleBulkDeinitCmdObj().Run(); err != nil { return gui.surfaceError(err) } @@ -274,7 +274,7 @@ func (gui *Gui) handleBulkSubmoduleActionsMenu() error { func (gui *Gui) handleUpdateSubmodule(submodule *models.SubmoduleConfig) error { return gui.WithWaitingStatus(gui.Tr.LcUpdatingSubmoduleStatus, func() error { - gui.logSpan(gui.Tr.Spans.UpdateSubmodule) + gui.logAction(gui.Tr.Actions.UpdateSubmodule) err := gui.GitCommand.SubmoduleUpdate(submodule.Path) gui.handleCredentialsPopup(err) diff --git a/pkg/gui/tags_panel.go b/pkg/gui/tags_panel.go index 1bd168c04..1c5ece0c7 100644 --- a/pkg/gui/tags_panel.go +++ b/pkg/gui/tags_panel.go @@ -63,7 +63,7 @@ func (gui *Gui) withSelectedTag(f func(tag *models.Tag) error) func() error { // tag-specific handlers func (gui *Gui) handleCheckoutTag(tag *models.Tag) error { - gui.logSpan(gui.Tr.Spans.CheckoutTag) + gui.logAction(gui.Tr.Actions.CheckoutTag) if err := gui.handleCheckoutRef(tag.Name, handleCheckoutRefOptions{}); err != nil { return err } @@ -82,7 +82,7 @@ func (gui *Gui) handleDeleteTag(tag *models.Tag) error { title: gui.Tr.DeleteTagTitle, prompt: prompt, handleConfirm: func() error { - gui.logSpan(gui.Tr.Spans.DeleteTag) + gui.logAction(gui.Tr.Actions.DeleteTag) if err := gui.GitCommand.DeleteTag(tag.Name); err != nil { return gui.surfaceError(err) } @@ -105,7 +105,7 @@ func (gui *Gui) handlePushTag(tag *models.Tag) error { findSuggestionsFunc: gui.getRemoteSuggestionsFunc(), handleConfirm: func(response string) error { return gui.WithWaitingStatus(gui.Tr.PushingTagStatus, func() error { - gui.logSpan(gui.Tr.Spans.PushTag) + gui.logAction(gui.Tr.Actions.PushTag) err := gui.GitCommand.PushTag(response, tag.Name, gui.promptUserForCredential) gui.handleCredentialsPopup(err) diff --git a/pkg/gui/undoing.go b/pkg/gui/undoing.go index 9817e2762..3e75924cd 100644 --- a/pkg/gui/undoing.go +++ b/pkg/gui/undoing.go @@ -99,13 +99,13 @@ func (gui *Gui) reflogUndo() error { switch action.kind { case COMMIT, REBASE: - gui.logSpan(gui.Tr.Spans.Undo) + gui.logAction(gui.Tr.Actions.Undo) return true, gui.handleHardResetWithAutoStash(action.from, handleHardResetWithAutoStashOptions{ EnvVars: undoEnvVars, WaitingStatus: undoingStatus, }) case CHECKOUT: - gui.logSpan(gui.Tr.Spans.Undo) + gui.logAction(gui.Tr.Actions.Undo) return true, gui.handleCheckoutRef(action.from, handleCheckoutRefOptions{ EnvVars: undoEnvVars, WaitingStatus: undoingStatus, @@ -135,13 +135,13 @@ func (gui *Gui) reflogRedo() error { switch action.kind { case COMMIT, REBASE: - gui.logSpan(gui.Tr.Spans.Redo) + gui.logAction(gui.Tr.Actions.Redo) return true, gui.handleHardResetWithAutoStash(action.to, handleHardResetWithAutoStashOptions{ EnvVars: redoEnvVars, WaitingStatus: redoingStatus, }) case CHECKOUT: - gui.logSpan(gui.Tr.Spans.Redo) + gui.logAction(gui.Tr.Actions.Redo) return true, gui.handleCheckoutRef(action.to, handleCheckoutRefOptions{ EnvVars: redoEnvVars, WaitingStatus: redoingStatus, diff --git a/pkg/gui/workspace_reset_options_panel.go b/pkg/gui/workspace_reset_options_panel.go index aee2e4db4..a4eb0733f 100644 --- a/pkg/gui/workspace_reset_options_panel.go +++ b/pkg/gui/workspace_reset_options_panel.go @@ -21,7 +21,7 @@ func (gui *Gui) handleCreateResetMenu() error { red.Sprint(nukeStr), }, onPress: func() error { - gui.logSpan(gui.Tr.Spans.NukeWorkingTree) + gui.logAction(gui.Tr.Actions.NukeWorkingTree) if err := gui.GitCommand.ResetAndClean(); err != nil { return gui.surfaceError(err) } @@ -35,7 +35,7 @@ func (gui *Gui) handleCreateResetMenu() error { red.Sprint("git checkout -- ."), }, onPress: func() error { - gui.logSpan(gui.Tr.Spans.DiscardUnstagedFileChanges) + gui.logAction(gui.Tr.Actions.DiscardUnstagedFileChanges) if err := gui.GitCommand.DiscardAnyUnstagedFileChanges(); err != nil { return gui.surfaceError(err) } @@ -49,7 +49,7 @@ func (gui *Gui) handleCreateResetMenu() error { red.Sprint("git clean -fd"), }, onPress: func() error { - gui.logSpan(gui.Tr.Spans.RemoveUntrackedFiles) + gui.logAction(gui.Tr.Actions.RemoveUntrackedFiles) if err := gui.GitCommand.RemoveUntrackedFiles(); err != nil { return gui.surfaceError(err) } @@ -63,7 +63,7 @@ func (gui *Gui) handleCreateResetMenu() error { red.Sprint("git reset --soft HEAD"), }, onPress: func() error { - gui.logSpan(gui.Tr.Spans.SoftReset)