diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-06 09:54:38 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-06 19:34:32 +1000 |
commit | b1cda65dcfdc5465f9fca582105fb0aa741abff5 (patch) | |
tree | 8932f62ecf7fb560cf533d236a1c6180ca7a7601 /pkg | |
parent | 74ce65d9ff56e51d6e1c848c65c3a5bd51f6421e (diff) |
show error when user attempts to commit when no files are present
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/files_panel.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 2bbe4278e..f2ed2f3a3 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -380,6 +380,10 @@ func (gui *Gui) handleCommitPress() error { return gui.surfaceError(err) } + if gui.State.FileManager.GetItemsLength() == 0 { + return gui.createErrorPanel(gui.Tr.NoFilesStagedTitle) + } + if len(gui.stagedFiles()) == 0 { return gui.promptToStageAllAndRetry(gui.handleCommitPress) } @@ -428,6 +432,10 @@ func (gui *Gui) promptToStageAllAndRetry(retry func() error) error { } func (gui *Gui) handleAmendCommitPress() error { + if gui.State.FileManager.GetItemsLength() == 0 { + return gui.createErrorPanel(gui.Tr.NoFilesStagedTitle) + } + if len(gui.stagedFiles()) == 0 { return gui.promptToStageAllAndRetry(gui.handleAmendCommitPress) } @@ -458,6 +466,10 @@ func (gui *Gui) handleAmendCommitPress() error { // handleCommitEditorPress - handle when the user wants to commit changes via // their editor rather than via the popup panel func (gui *Gui) handleCommitEditorPress() error { + if gui.State.FileManager.GetItemsLength() == 0 { + return gui.createErrorPanel(gui.Tr.NoFilesStagedTitle) + } + if len(gui.stagedFiles()) == 0 { return gui.promptToStageAllAndRetry(gui.handleCommitEditorPress) } |