diff options
author | Davyd McColl <davydm@gmail.com> | 2020-11-18 16:17:16 +0200 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-11-28 10:27:28 +1100 |
commit | 26d5444919a04169d970f662cd1ac6ce4de026a1 (patch) | |
tree | de17a2ffe09bb52f36787b64ab3634f1350418c1 /pkg | |
parent | e05c41828c7d70f207d9f1175c6c749646c4c361 (diff) |
:sparkles: implement quick commit when no files staged, if configured to do so
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/config/user_config.go | 24 | ||||
-rw-r--r-- | pkg/gui/files_panel.go | 13 |
2 files changed, 25 insertions, 12 deletions
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 216869f19..5891071b7 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -17,16 +17,17 @@ type UserConfig struct { } type GuiConfig struct { - 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"` - Theme ThemeConfig `yaml:"theme"` - CommitLength CommitLengthConfig `yaml:"commitLength"` + 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"` + Theme ThemeConfig `yaml:"theme"` + CommitLength CommitLengthConfig `yaml:"commitLength"` + SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"` } type ThemeConfig struct { @@ -280,7 +281,8 @@ func GetDefaultConfig() *UserConfig { SelectedLineBgColor: []string{"default"}, SelectedRangeBgColor: []string{"blue"}, }, - CommitLength: CommitLengthConfig{Show: true}, + CommitLength: CommitLengthConfig{Show: true}, + SkipNoStagedFilesWarning: false, }, Git: GitConfig{ Paging: PagingConfig{ diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 7d2b074ca..56c375af7 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -301,8 +301,19 @@ func (gui *Gui) commitPrefixConfigForRepo() *config.CommitPrefixConfig { return &cfg } +func (gui *Gui) canCommitNow() bool { + if gui.Config.GetUserConfig().Gui.SkipNoStagedFilesWarning { + err := gui.GitCommand.StageAll() + return err == nil + } + if len(gui.stagedFiles()) > 0 { + return true + } + return false +} + func (gui *Gui) handleCommitPress() error { - if len(gui.stagedFiles()) == 0 { + if !gui.canCommitNow() { return gui.promptToStageAllAndRetry(gui.handleCommitPress) } |