mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +02:00
The four horsemen of stashing
This commit is contained in:
parent
6f7038c827
commit
1ae2dc9941
3 changed files with 41 additions and 15 deletions
|
@ -38,7 +38,6 @@ func (self *StashCommands) Apply(index int) error {
|
|||
}
|
||||
|
||||
// Save save stash
|
||||
// TODO: before calling this, check if there is anything to save
|
||||
func (self *StashCommands) Save(message string) error {
|
||||
return self.cmd.New("git stash save " + self.cmd.Quote(message)).Run()
|
||||
}
|
||||
|
@ -53,6 +52,19 @@ func (self *StashCommands) StashAndKeepIndex(message string) error {
|
|||
return self.cmd.New(fmt.Sprintf("git stash save %s --keep-index", self.cmd.Quote(message))).Run()
|
||||
}
|
||||
|
||||
func (self *StashCommands) StashUnstagedChanges(message string) error {
|
||||
if err := self.cmd.New("git commit -m \"WIP\"").Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := self.Save(message); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := self.cmd.New("git reset --soft HEAD^").Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SaveStagedChanges stashes only the currently staged changes. This takes a few steps
|
||||
// shoutouts to Joe on https://stackoverflow.com/questions/14759748/stashing-only-staged-changes-in-git-is-it-possible
|
||||
func (self *StashCommands) SaveStagedChanges(message string) error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue