mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-06 22:33:07 +02:00
Auto-stash if necessary when cherry-picking commits
This commit is contained in:
@ -78,7 +78,16 @@ func (self *CherryPickHelper) Paste() error {
|
||||
}),
|
||||
HandleConfirm: func() error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.CherryPickingStatus, func(gocui.Task) error {
|
||||
mustStash := IsWorkingTreeDirty(self.c.Model().Files)
|
||||
|
||||
self.c.LogAction(self.c.Tr.Actions.CherryPick)
|
||||
|
||||
if mustStash {
|
||||
if err := self.c.Git().Stash.Push(self.c.Tr.AutoStashForCherryPicking); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
result := self.c.Git().Rebase.CherryPickCommits(self.getData().CherryPickedCommits)
|
||||
err := self.rebaseHelper.CheckMergeOrRebase(result)
|
||||
if err != nil {
|
||||
@ -96,7 +105,17 @@ func (self *CherryPickHelper) Paste() error {
|
||||
if !isInCherryPick {
|
||||
self.getData().DidPaste = true
|
||||
self.rerender()
|
||||
|
||||
if mustStash {
|
||||
if err := self.c.Git().Stash.Pop(0); err != nil {
|
||||
return err
|
||||
}
|
||||
self.c.Refresh(types.RefreshOptions{
|
||||
Scope: []types.RefreshableView{types.STASH, types.FILES},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
},
|
||||
|
@ -451,6 +451,7 @@ type TranslationSet struct {
|
||||
AutoStashForCheckout string
|
||||
AutoStashForNewBranch string
|
||||
AutoStashForMovingPatchToIndex string
|
||||
AutoStashForCherryPicking string
|
||||
Discard string
|
||||
DiscardChangesTitle string
|
||||
DiscardFileChangesTooltip string
|
||||
@ -1547,6 +1548,7 @@ func EnglishTranslationSet() *TranslationSet {
|
||||
AutoStashForCheckout: "Auto-stashing changes for checking out %s",
|
||||
AutoStashForNewBranch: "Auto-stashing changes for creating new branch %s",
|
||||
AutoStashForMovingPatchToIndex: "Auto-stashing changes for moving custom patch to index from %s",
|
||||
AutoStashForCherryPicking: "Auto-stashing changes for cherry-picking commits",
|
||||
Discard: "Discard",
|
||||
DiscardFileChangesTooltip: "View options for discarding changes to the selected file.",
|
||||
DiscardChangesTitle: "Discard changes",
|
||||
|
Reference in New Issue
Block a user