1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-02 09:21:40 +02:00

Replace uses of "git stash save" with "git stash push"

Save has been deprecated for a while, push is the recommended way to save a
stash. Push has been available since 2.13, so we can use it without problems.
This commit is contained in:
Stefan Haller 2023-07-01 16:22:32 +02:00
parent 1827380c69
commit 30ce7c8085
6 changed files with 15 additions and 15 deletions

View File

@ -221,7 +221,7 @@ func (self *PatchCommands) MovePatchToSelectedCommit(commits []*models.Commit, s
func (self *PatchCommands) MovePatchIntoIndex(commits []*models.Commit, commitIdx int, stash bool) error {
if stash {
if err := self.stash.Save(self.Tr.StashPrefix + commits[commitIdx].Sha); err != nil {
if err := self.stash.Push(self.Tr.StashPrefix + commits[commitIdx].Sha); err != nil {
return err
}
}

View File

@ -52,9 +52,9 @@ func (self *StashCommands) Apply(index int) error {
return self.cmd.New(cmdArgs).Run()
}
// Save save stash
func (self *StashCommands) Save(message string) error {
cmdArgs := NewGitCmd("stash").Arg("save", message).
// Push push stash
func (self *StashCommands) Push(message string) error {
cmdArgs := NewGitCmd("stash").Arg("push", "-m", message).
ToArgv()
return self.cmd.New(cmdArgs).Run()
@ -94,7 +94,7 @@ func (self *StashCommands) ShowStashEntryCmdObj(index int, ignoreWhitespace bool
}
func (self *StashCommands) StashAndKeepIndex(message string) error {
cmdArgs := NewGitCmd("stash").Arg("save", "--keep-index", message).
cmdArgs := NewGitCmd("stash").Arg("push", "--keep-index", "-m", message).
ToArgv()
return self.cmd.New(cmdArgs).Run()
@ -108,7 +108,7 @@ func (self *StashCommands) StashUnstagedChanges(message string) error {
).Run(); err != nil {
return err
}
if err := self.Save(message); err != nil {
if err := self.Push(message); err != nil {
return err
}
@ -130,7 +130,7 @@ func (self *StashCommands) SaveStagedChanges(message string) error {
return err
}
if err := self.Save(message); err != nil {
if err := self.Push(message); err != nil {
return err
}
@ -172,7 +172,7 @@ func (self *StashCommands) SaveStagedChanges(message string) error {
func (self *StashCommands) StashIncludeUntrackedChanges(message string) error {
return self.cmd.New(
NewGitCmd("stash").Arg("save", "--include-untracked", message).
NewGitCmd("stash").Arg("push", "--include-untracked", "-m", message).
ToArgv(),
).Run()
}

View File

@ -37,10 +37,10 @@ func TestStashPop(t *testing.T) {
func TestStashSave(t *testing.T) {
runner := oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"stash", "save", "A stash message"}, "", nil)
ExpectGitArgs([]string{"stash", "push", "-m", "A stash message"}, "", nil)
instance := buildStashCommands(commonDeps{runner: runner})
assert.NoError(t, instance.Save("A stash message"))
assert.NoError(t, instance.Push("A stash message"))
runner.CheckForMissingCalls()
}

View File

@ -697,7 +697,7 @@ func (self *FilesController) createStashMenu() error {
if !self.c.Helpers().WorkingTree.IsWorkingTreeDirty() {
return self.c.ErrorMsg(self.c.Tr.NoFilesToStash)
}
return self.handleStashSave(self.c.Git().Stash.Save, self.c.Tr.Actions.StashAllChanges)
return self.handleStashSave(self.c.Git().Stash.Push, self.c.Tr.Actions.StashAllChanges)
},
Key: 'a',
},
@ -740,7 +740,7 @@ func (self *FilesController) createStashMenu() error {
return self.handleStashSave(self.c.Git().Stash.StashUnstagedChanges, self.c.Tr.Actions.StashUnstagedChanges)
}
// ordinary stash
return self.handleStashSave(self.c.Git().Stash.Save, self.c.Tr.Actions.StashUnstagedChanges)
return self.handleStashSave(self.c.Git().Stash.Push, self.c.Tr.Actions.StashUnstagedChanges)
},
Key: 'u',
},
@ -749,7 +749,7 @@ func (self *FilesController) createStashMenu() error {
}
func (self *FilesController) stash() error {
return self.handleStashSave(self.c.Git().Stash.Save, self.c.Tr.Actions.StashAllChanges)
return self.handleStashSave(self.c.Git().Stash.Push, self.c.Tr.Actions.StashAllChanges)
}
func (self *FilesController) createResetToUpstreamMenu() error {

View File

@ -65,7 +65,7 @@ func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions
Title: self.c.Tr.AutoStashTitle,
Prompt: self.c.Tr.AutoStashPrompt,
HandleConfirm: func() error {
if err := self.c.Git().Stash.Save(self.c.Tr.StashPrefix + ref); err != nil {
if err := self.c.Git().Stash.Push(self.c.Tr.StashPrefix + ref); err != nil {
return self.c.Error(err)
}
if err := self.c.Git().Branch.Checkout(ref, cmdOptions); err != nil {

View File

@ -249,7 +249,7 @@ func (self *UndoController) hardResetWithAutoStash(commitSha string, options har
Prompt: self.c.Tr.AutoStashPrompt,
HandleConfirm: func() error {
return self.c.WithWaitingStatus(options.WaitingStatus, func(gocui.Task) error {
if err := self.c.Git().Stash.Save(self.c.Tr.StashPrefix + commitSha); err != nil {
if err := self.c.Git().Stash.Push(self.c.Tr.StashPrefix + commitSha); err != nil {
return self.c.Error(err)
}
if err := reset(); err != nil {