mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-14 00:21:48 +03:00
Add confirmation for hard reset when there are uncommitted changes
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
)
|
||||
@ -150,15 +151,22 @@ func (self *FilesController) createResetMenu() error {
|
||||
red.Sprint("git reset --hard HEAD"),
|
||||
},
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.HardReset)
|
||||
if err := self.c.Git().WorkingTree.ResetHard("HEAD"); err != nil {
|
||||
return err
|
||||
}
|
||||
return self.c.ConfirmIf(helpers.IsWorkingTreeDirty(self.c.Model().Files),
|
||||
types.ConfirmOpts{
|
||||
Title: self.c.Tr.Actions.HardReset,
|
||||
Prompt: self.c.Tr.ResetHardConfirmation,
|
||||
HandleConfirm: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.HardReset)
|
||||
if err := self.c.Git().WorkingTree.ResetHard("HEAD"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.Refresh(
|
||||
types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}},
|
||||
)
|
||||
return nil
|
||||
self.c.Refresh(
|
||||
types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}},
|
||||
)
|
||||
return nil
|
||||
},
|
||||
})
|
||||
},
|
||||
Key: 'h',
|
||||
},
|
||||
|
Reference in New Issue
Block a user