diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-01-29 13:43:23 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-29 13:43:23 +1100 |
commit | 18db5eafd4d17c91d92a92c95f80ec71c168ed1c (patch) | |
tree | ef11bf0aba7f2d2d34d5d4c48795deff9b1d9355 | |
parent | 679b0456f3db7c505b398def84e7d023e5b55a8d (diff) | |
parent | 67fb28e2b89c7e9dd9cb58f6ad1acb76d4c78fa4 (diff) |
Merge pull request #2384 from stefanhaller/disable-reword-in-editor-prompt
-rw-r--r-- | docs/Config.md | 1 | ||||
-rw-r--r-- | pkg/config/user_config.go | 68 | ||||
-rw-r--r-- | pkg/gui/controllers/local_commits_controller.go | 52 |
3 files changed, 65 insertions, 56 deletions
diff --git a/docs/Config.md b/docs/Config.md index e30bf6786..f7e236843 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -61,6 +61,7 @@ gui: showIcons: false commandLogSize: 8 splitDiff: 'auto' # one of 'auto' | 'always' + skipRewordInEditorWarning: false # for skipping the confirmation before launching the reword editor git: paging: colorArg: always diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 59244f3f4..705553407 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -27,29 +27,30 @@ type RefresherConfig struct { } type GuiConfig struct { - AuthorColors map[string]string `yaml:"authorColors"` - BranchColors map[string]string `yaml:"branchColors"` - ScrollHeight int `yaml:"scrollHeight"` - ScrollPastBottom bool `yaml:"scrollPastBottom"` - MouseEvents bool `yaml:"mouseEvents"` - SkipUnstageLineWarning bool `yaml:"skipUnstageLineWarning"` - SkipStashWarning bool `yaml:"skipStashWarning"` - SidePanelWidth float64 `yaml:"sidePanelWidth"` - ExpandFocusedSidePanel bool `yaml:"expandFocusedSidePanel"` - MainPanelSplitMode string `yaml:"mainPanelSplitMode"` - Language string `yaml:"language"` - TimeFormat string `yaml:"timeFormat"` - Theme ThemeConfig `yaml:"theme"` - CommitLength CommitLengthConfig `yaml:"commitLength"` - SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"` - ShowListFooter bool `yaml:"showListFooter"` - ShowFileTree bool `yaml:"showFileTree"` - ShowRandomTip bool `yaml:"showRandomTip"` - ShowCommandLog bool `yaml:"showCommandLog"` - ShowBottomLine bool `yaml:"showBottomLine"` - ShowIcons bool `yaml:"showIcons"` - CommandLogSize int `yaml:"commandLogSize"` - SplitDiff string `yaml:"splitDiff"` + AuthorColors map[string]string `yaml:"authorColors"` + BranchColors map[string]string `yaml:"branchColors"` + ScrollHeight int `yaml:"scrollHeight"` + ScrollPastBottom bool `yaml:"scrollPastBottom"` + MouseEvents bool `yaml:"mouseEvents"` + SkipUnstageLineWarning bool `yaml:"skipUnstageLineWarning"` + SkipStashWarning bool `yaml:"skipStashWarning"` + SidePanelWidth float64 `yaml:"sidePanelWidth"` + ExpandFocusedSidePanel bool `yaml:"expandFocusedSidePanel"` + MainPanelSplitMode string `yaml:"mainPanelSplitMode"` + Language string `yaml:"language"` + TimeFormat string `yaml:"timeFormat"` + Theme ThemeConfig `yaml:"theme"` + CommitLength CommitLengthConfig `yaml:"commitLength"` + SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"` + ShowListFooter bool `yaml:"showListFooter"` + ShowFileTree bool `yaml:"showFileTree"` + ShowRandomTip bool `yaml:"showRandomTip"` + ShowCommandLog bool `yaml:"showCommandLog"` + ShowBottomLine bool `yaml:"showBottomLine"` + ShowIcons bool `yaml:"showIcons"` + CommandLogSize int `yaml:"commandLogSize"` + SplitDiff string `yaml:"splitDiff"` + SkipRewordInEditorWarning bool `yaml:"skipRewordInEditorWarning"` } type ThemeConfig struct { @@ -368,16 +369,17 @@ func GetDefaultConfig() *UserConfig { UnstagedChangesColor: []string{"red"}, DefaultFgColor: []string{"default"}, }, - CommitLength: CommitLengthConfig{Show: true}, - SkipNoStagedFilesWarning: false, - ShowListFooter: true, - ShowCommandLog: true, - ShowBottomLine: true, - ShowFileTree: true, - ShowRandomTip: true, - ShowIcons: false, - CommandLogSize: 8, - SplitDiff: "auto", + CommitLength: CommitLengthConfig{Show: true}, + SkipNoStagedFilesWarning: false, + ShowListFooter: true, + ShowCommandLog: true, + ShowBottomLine: true, + ShowFileTree: true, + ShowRandomTip: true, + ShowIcons: false, + CommandLogSize: 8, + SplitDiff: "auto", + SkipRewordInEditorWarning: false, }, Git: GitConfig{ Paging: PagingConfig{ diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 6539a13af..3a9aff86b 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -226,6 +226,26 @@ func (self *LocalCommitsController) reword(commit *models.Commit) error { }) } +func (self *LocalCommitsController) doRewordEditor() error { + self.c.LogAction(self.c.Tr.Actions.RewordCommit) + + if self.context().GetSelectedLineIdx() == 0 { + return self.c.RunSubprocessAndRefresh(self.os.Cmd.New("git commit --allow-empty --amend --only")) + } + + subProcess, err := self.git.Rebase.RewordCommitInEditor( + self.model.Commits, self.context().GetSelectedLineIdx(), + ) + if err != nil { + return self.c.Error(err) + } + if subProcess != nil { + return self.c.RunSubprocessAndRefresh(subProcess) + } + + return nil +} + func (self *LocalCommitsController) rewordEditor(commit *models.Commit) error { midRebase, err := self.handleMidRebaseCommand("reword", commit) if err != nil { @@ -235,29 +255,15 @@ func (self *LocalCommitsController) rewordEditor(commit *models.Commit) error { return nil } - return self.c.Confirm(types.ConfirmOpts{ - Title: self.c.Tr.RewordInEditorTitle, - Prompt: self.c.Tr.RewordInEditorPrompt, - HandleConfirm: func() error { - self.c.LogAction(self.c.Tr.Actions.RewordCommit) - - if self.context().GetSelectedLineIdx() == 0 { - return self.c.RunSubprocessAndRefresh(self.os.Cmd.New("git commit --allow-empty --amend --only")) - } - - subProcess, err := self.git.Rebase.RewordCommitInEditor( - self.model.Commits, self.context().GetSelectedLineIdx(), - ) - if err != nil { - return self.c.Error(err) - } - if subProcess != nil { - return self.c.RunSubprocessAndRefresh(subProcess) - } - - return nil - }, - }) + if self.c.UserConfig.Gui.SkipRewordInEditorWarning { + return self.doRewordEditor() + } else { + return self.c.Confirm(types.ConfirmOpts{ + Title: self.c.Tr.RewordInEditorTitle, + Prompt: self.c.Tr.RewordInEditorPrompt, + HandleConfirm: self.doRewordEditor, + }) + } } func (self *LocalCommitsController) drop(commit *models.Commit) error { |