Discard staged changes only
This commit is contained in:
@@ -25,6 +25,10 @@ func NewStashCommands(
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
func (self *FilesController) createResetMenu() error {
|
||||
red := style.FgRed
|
||||
|
||||
nukeStr := "reset --hard HEAD && git clean -fd"
|
||||
nukeStr := "git reset --hard HEAD && git clean -fd"
|
||||
if len(self.model.Submodules) > 0 {
|
||||
nukeStr = fmt.Sprintf("%s (%s)", nukeStr, self.c.Tr.LcAndResetSubmodules)
|
||||
}
|
||||
@@ -64,6 +64,28 @@ func (self *FilesController) createResetMenu() error {
|
||||
},
|
||||
Key: 'c',
|
||||
},
|
||||
{
|
||||
LabelColumns: []string{
|
||||
self.c.Tr.LcDiscardStagedChanges,
|
||||
red.Sprint("stash staged and drop stash"),
|
||||
},
|
||||
Tooltip: "This will create a new stash entry containing only staged files and then drop it.",
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.RemoveStagedFiles)
|
||||
if !self.helpers.WorkingTree.IsWorkingTreeDirty() {
|
||||
return self.c.ErrorMsg(self.c.Tr.NoTrackedStagedFilesStash)
|
||||
}
|
||||
if err := self.git.Stash.SaveStagedChanges("[lazygit] tmp stash"); err != nil {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
if err := self.git.Stash.DropNewest(); err != nil {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}})
|
||||
},
|
||||
Key: 'S',
|
||||
},
|
||||
{
|
||||
LabelColumns: []string{
|
||||
self.c.Tr.LcSoftReset,
|
||||
|
||||
@@ -265,6 +265,7 @@ type TranslationSet struct {
|
||||
LcDiscardAllChangesToAllFiles string
|
||||
LcDiscardAnyUnstagedChanges string
|
||||
LcDiscardUntrackedFiles string
|
||||
LcDiscardStagedChanges string
|
||||
LcHardReset string
|
||||
LcViewResetOptions string
|
||||
LcCreateFixupCommit string
|
||||
@@ -594,6 +595,7 @@ type Actions struct {
|
||||
NukeWorkingTree string
|
||||
DiscardUnstagedFileChanges string
|
||||
RemoveUntrackedFiles string
|
||||
RemoveStagedFiles string
|
||||
SoftReset string
|
||||
MixedReset string
|
||||
HardReset string
|
||||
@@ -883,6 +885,7 @@ func EnglishTranslationSet() TranslationSet {
|
||||
LcDiscardAllChangesToAllFiles: "nuke working tree",
|
||||
LcDiscardAnyUnstagedChanges: "discard unstaged changes",
|
||||
LcDiscardUntrackedFiles: "discard untracked files",
|
||||
LcDiscardStagedChanges: "discard staged changes",
|
||||
LcHardReset: "hard reset",
|
||||
LcViewResetOptions: `view reset options`,
|
||||
LcCreateFixupCommit: `create fixup commit for this commit`,
|
||||
@@ -1193,6 +1196,7 @@ func EnglishTranslationSet() TranslationSet {
|
||||
NukeWorkingTree: "Nuke working tree",
|
||||
DiscardUnstagedFileChanges: "Discard unstaged file changes",
|
||||
RemoveUntrackedFiles: "Remove untracked files",
|
||||
RemoveStagedFiles: "Remove staged files",
|
||||
SoftReset: "Soft reset",
|
||||
MixedReset: "Mixed reset",
|
||||
HardReset: "Hard reset",
|
||||
|
||||
Reference in New Issue
Block a user