mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-12 15:53:33 -04:00
Extract a helper that stages all files and then runs a handler
Prepares for using it when the user confirms the "No files staged" prompt too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
bd4062a1e7
commit
668f4032da
@@ -274,15 +274,7 @@ func (self *WorkingTreeHelper) WithEnsureCommittableFiles(handler func() error)
|
||||
}
|
||||
|
||||
if self.c.UserConfig().Gui.SkipNoStagedFilesWarning {
|
||||
self.c.LogAction(self.c.Tr.Actions.StageAllFiles)
|
||||
if err := self.c.Git().WorkingTree.StageAll(false); err != nil {
|
||||
return err
|
||||
}
|
||||
self.c.Refresh(types.RefreshOptions{
|
||||
Scope: []types.RefreshableView{types.FILES},
|
||||
Then: handler,
|
||||
})
|
||||
return nil
|
||||
return self.stageAllAndThen(handler)
|
||||
}
|
||||
|
||||
return self.promptToStageAllAndRetry(handler)
|
||||
@@ -291,6 +283,18 @@ func (self *WorkingTreeHelper) WithEnsureCommittableFiles(handler func() error)
|
||||
return handler()
|
||||
}
|
||||
|
||||
func (self *WorkingTreeHelper) stageAllAndThen(then func() error) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.StageAllFiles)
|
||||
if err := self.c.Git().WorkingTree.StageAll(false); err != nil {
|
||||
return err
|
||||
}
|
||||
self.c.Refresh(types.RefreshOptions{
|
||||
Scope: []types.RefreshableView{types.FILES},
|
||||
Then: then,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *WorkingTreeHelper) promptToStageAllAndRetry(retry func() error) error {
|
||||
self.c.Confirm(types.ConfirmOpts{
|
||||
Title: self.c.Tr.NoFilesStagedTitle,
|
||||
|
||||
Reference in New Issue
Block a user