1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-24 05:36:19 +02:00

👌 update as per PR commentary

This commit is contained in:
Davyd McColl 2020-11-23 10:14:15 +02:00 committed by Jesse Duffield
parent 196761a40a
commit 860370a845

View File

@ -301,19 +301,26 @@ func (gui *Gui) commitPrefixConfigForRepo() *config.CommitPrefixConfig {
return &cfg return &cfg
} }
func (gui *Gui) canCommitNow() bool { func (gui *Gui) prepareFilesForCommit() error {
if len(gui.stagedFiles()) > 0 { noStagedFiles := len(gui.stagedFiles()) == 0
return true if noStagedFiles && gui.Config.GetUserConfig().Gui.SkipNoStagedFilesWarning {
}
if gui.Config.GetUserConfig().Gui.SkipNoStagedFilesWarning {
err := gui.GitCommand.StageAll() err := gui.GitCommand.StageAll()
return err == nil if err != nil {
return err
}
return gui.refreshFilesAndSubmodules()
} }
return false
return nil
} }
func (gui *Gui) handleCommitPress() error { func (gui *Gui) handleCommitPress() error {
if !gui.canCommitNow() { if err := gui.prepareFilesForCommit(); err != nil {
return gui.surfaceError(err)
}
if len(gui.stagedFiles()) == 0 {
return gui.promptToStageAllAndRetry(gui.handleCommitPress) return gui.promptToStageAllAndRetry(gui.handleCommitPress)
} }