This commit is contained in:
Shivam Bhalla 2026-09-05 15:57:21 +02:00 committed by GitHub
commit 1db43ff532
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 0 deletions

View file

@ -1479,6 +1479,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)
}

View 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"),
)
},
})

View file

@ -445,6 +445,7 @@ var tests = []*components.IntegrationTest{
stash.StashAll,
stash.StashAndKeepIndex,
stash.StashIncludingUntrackedFiles,
stash.StashNoTrackedChanges,
stash.StashStaged,
stash.StashStagedPartialFile,
stash.StashUnstaged,