1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-10 04:07:18 +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
}
func (gui *Gui) canCommitNow() bool {
if len(gui.stagedFiles()) > 0 {
return true
}
if gui.Config.GetUserConfig().Gui.SkipNoStagedFilesWarning {
func (gui *Gui) prepareFilesForCommit() error {
noStagedFiles := len(gui.stagedFiles()) == 0
if noStagedFiles && gui.Config.GetUserConfig().Gui.SkipNoStagedFilesWarning {
err := gui.GitCommand.StageAll()
return err == nil
if err != nil {
return err
}
return gui.refreshFilesAndSubmodules()
}
return false
return nil
}
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)
}