mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-08 22:36:49 +02:00
Auto-stash if necessary when reverting commits
This commit is contained in:
@ -873,12 +873,30 @@ func (self *LocalCommitsController) revert(commits []*models.Commit, start, end
|
||||
HandleConfirm: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.RevertCommit)
|
||||
return self.c.WithWaitingStatusSync(self.c.Tr.RevertingStatus, func() error {
|
||||
mustStash := helpers.IsWorkingTreeDirty(self.c.Model().Files)
|
||||
|
||||
if mustStash {
|
||||
if err := self.c.Git().Stash.Push(self.c.Tr.AutoStashForReverting); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
result := self.c.Git().Commit.Revert(hashes, isMerge)
|
||||
if err := self.c.Helpers().MergeAndRebase.CheckMergeOrRebaseWithRefreshOptions(result, types.RefreshOptions{Mode: types.SYNC}); err != nil {
|
||||
return err
|
||||
}
|
||||
self.context().MoveSelection(len(commits))
|
||||
self.context().FocusLine()
|
||||
|
||||
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
|
||||
})
|
||||
},
|
||||
|
@ -452,6 +452,7 @@ type TranslationSet struct {
|
||||
AutoStashForNewBranch string
|
||||
AutoStashForMovingPatchToIndex string
|
||||
AutoStashForCherryPicking string
|
||||
AutoStashForReverting string
|
||||
Discard string
|
||||
DiscardChangesTitle string
|
||||
DiscardFileChangesTooltip string
|
||||
@ -1549,6 +1550,7 @@ func EnglishTranslationSet() *TranslationSet {
|
||||
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",
|
||||
AutoStashForReverting: "Auto-stashing changes for reverting commits",
|
||||
Discard: "Discard",
|
||||
DiscardFileChangesTooltip: "View options for discarding changes to the selected file.",
|
||||
DiscardChangesTitle: "Discard changes",
|
||||
|
Reference in New Issue
Block a user