mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-25 22:32:13 +02:00
✨ implement quick commit when no files staged, if configured to do so
This commit is contained in:
committed by
Jesse Duffield
parent
e05c41828c
commit
26d5444919
1
.gitignore
vendored
1
.gitignore
vendored
@@ -31,3 +31,4 @@ test/integration/*/used_config/
|
|||||||
# these sample hooks waste too space space
|
# these sample hooks waste too space space
|
||||||
test/integration/*/expected/.git_keep/hooks/
|
test/integration/*/expected/.git_keep/hooks/
|
||||||
!.git_keep/
|
!.git_keep/
|
||||||
|
lazygit.exe
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ type GuiConfig struct {
|
|||||||
MainPanelSplitMode string `yaml:"mainPanelSplitMode"`
|
MainPanelSplitMode string `yaml:"mainPanelSplitMode"`
|
||||||
Theme ThemeConfig `yaml:"theme"`
|
Theme ThemeConfig `yaml:"theme"`
|
||||||
CommitLength CommitLengthConfig `yaml:"commitLength"`
|
CommitLength CommitLengthConfig `yaml:"commitLength"`
|
||||||
|
SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ThemeConfig struct {
|
type ThemeConfig struct {
|
||||||
@@ -281,6 +282,7 @@ func GetDefaultConfig() *UserConfig {
|
|||||||
SelectedRangeBgColor: []string{"blue"},
|
SelectedRangeBgColor: []string{"blue"},
|
||||||
},
|
},
|
||||||
CommitLength: CommitLengthConfig{Show: true},
|
CommitLength: CommitLengthConfig{Show: true},
|
||||||
|
SkipNoStagedFilesWarning: false,
|
||||||
},
|
},
|
||||||
Git: GitConfig{
|
Git: GitConfig{
|
||||||
Paging: PagingConfig{
|
Paging: PagingConfig{
|
||||||
|
|||||||
@@ -301,8 +301,19 @@ func (gui *Gui) commitPrefixConfigForRepo() *config.CommitPrefixConfig {
|
|||||||
return &cfg
|
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 {
|
func (gui *Gui) handleCommitPress() error {
|
||||||
if len(gui.stagedFiles()) == 0 {
|
if !gui.canCommitNow() {
|
||||||
return gui.promptToStageAllAndRetry(gui.handleCommitPress)
|
return gui.promptToStageAllAndRetry(gui.handleCommitPress)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user