feat: add rename stash

This commit is contained in:
Ryooooooga 2022-10-14 22:19:53 +09:00
parent 8f3ccd07db
commit 11316b7a48
No known key found for this signature in database
GPG key ID: 07CF200DFCC20C25
17 changed files with 132 additions and 7 deletions

View file

@ -2,6 +2,7 @@ package git_commands
import (
"fmt"
"strings"
"github.com/jesseduffield/lazygit/pkg/commands/loaders"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
@ -29,8 +30,9 @@ func (self *StashCommands) DropNewest() error {
return self.cmd.New("git stash drop").Run()
}
func (self *StashCommands) Drop(index int) error {
return self.cmd.New(fmt.Sprintf("git stash drop stash@{%d}", index)).Run()
func (self *StashCommands) Drop(index int) (string, error) {
output, _, err := self.cmd.New(fmt.Sprintf("git stash drop stash@{%d}", index)).RunWithOutputs()
return output, err
}
func (self *StashCommands) Pop(index int) error {
@ -46,6 +48,14 @@ func (self *StashCommands) Save(message string) error {
return self.cmd.New("git stash save " + self.cmd.Quote(message)).Run()
}
func (self *StashCommands) Store(sha string, message string) error {
trimmedMessage := strings.Trim(message, " \t")
if len(trimmedMessage) > 0 {
return self.cmd.New(fmt.Sprintf("git stash store %s -m %s", self.cmd.Quote(sha), self.cmd.Quote(trimmedMessage))).Run()
}
return self.cmd.New(fmt.Sprintf("git stash store %s", self.cmd.Quote(sha))).Run()
}
func (self *StashCommands) ShowStashEntryCmdObj(index int) oscommands.ICmdObj {
cmdStr := fmt.Sprintf("git stash show -p --stat --color=%s --unified=%d stash@{%d}", self.UserConfig.Git.Paging.ColorArg, self.UserConfig.Git.DiffContextSize, index)