summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavyd McColl <davydm@gmail.com>2020-11-18 16:17:16 +0200
committerJesse Duffield <jessedduffield@gmail.com>2020-11-28 10:27:28 +1100
commit26d5444919a04169d970f662cd1ac6ce4de026a1 (patch)
treede17a2ffe09bb52f36787b64ab3634f1350418c1
parente05c41828c7d70f207d9f1175c6c749646c4c361 (diff)
:sparkles: implement quick commit when no files staged, if configured to do so
-rw-r--r--.gitignore1
-rw-r--r--pkg/config/user_config.go24
-rw-r--r--pkg/gui/files_panel.go13
3 files changed, 26 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
index 3e8fd3b92..481e36162 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,4 @@ test/integration/*/used_config/
# these sample hooks waste too space space
test/integration/*/expected/.git_keep/hooks/
!.git_keep/
+lazygit.exe
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)
}