mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Fix: Show error when stashing with only untracked files
This commit is contained in:
parent
f162dc5aec
commit
c479409dfa
|
|
@ -1477,6 +1477,9 @@ func (self *FilesController) hasPathStagedChanges(node *filetree.FileNode) bool
|
|||
}
|
||||
|
||||
func (self *FilesController) stash() error {
|
||||
if !self.c.Helpers().WorkingTree.IsWorkingTreeDirtyExceptSubmodules() {
|
||||
return errors.New(self.c.Tr.NoFilesToStash)
|
||||
}
|
||||
return self.handleStashSave(self.c.Git().Stash.Push, self.c.Tr.Actions.StashAllChanges)
|
||||
}
|
||||
|
||||
|
|
|
|||
33
pkg/integration/tests/stash/stash_no_tracked_changes.go
Normal file
33
pkg/integration/tests/stash/stash_no_tracked_changes.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package stash
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var StashNoTrackedChanges = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Pressing stash with only untracked files shows an error",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFile("untracked", "content")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Contains("untracked"),
|
||||
).
|
||||
Press(keys.Files.StashAllChanges)
|
||||
|
||||
t.ExpectPopup().Alert().
|
||||
Title(Equals("Error")).
|
||||
Content(Contains("You have no files to stash")).
|
||||
Confirm()
|
||||
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Contains("untracked"),
|
||||
)
|
||||
},
|
||||
})
|
||||
|
|
@ -434,6 +434,7 @@ var tests = []*components.IntegrationTest{
|
|||
stash.StashAll,
|
||||
stash.StashAndKeepIndex,
|
||||
stash.StashIncludingUntrackedFiles,
|
||||
stash.StashNoTrackedChanges,
|
||||
stash.StashStaged,
|
||||
stash.StashStagedPartialFile,
|
||||
stash.StashUnstaged,
|
||||
|
|
|
|||
Loading…
Reference in a new issue