mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-30 17:10:17 -05:00
Extract stageAllScope from toggleStagedAllWithLock
Whether stage-all may be used is going to depend on what it stages. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
35909f65d8
commit
d2675b7dea
1 file changed
+27
-5
@@ -993,22 +993,44 @@ func (self *FilesController) toggleStagedAll() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// What staging all files stages
|
||||
type stageAllScope int
|
||||
|
||||
const (
|
||||
// Only the files that are visible, because a text filter is active
|
||||
stageAllVisibleFiles stageAllScope = iota
|
||||
// Only tracked files, because only those are shown
|
||||
stageAllTrackedFiles
|
||||
stageAllFiles
|
||||
)
|
||||
|
||||
func (self *FilesController) stageAllScope() stageAllScope {
|
||||
if self.context().IsFiltering() {
|
||||
return stageAllVisibleFiles
|
||||
}
|
||||
if self.context().GetStatusFilter() == filetree.DisplayTracked {
|
||||
return stageAllTrackedFiles
|
||||
}
|
||||
return stageAllFiles
|
||||
}
|
||||
|
||||
func (self *FilesController) toggleStagedAllWithLock() error {
|
||||
root := self.context().FileTreeViewModel.GetRoot()
|
||||
|
||||
stage := func(unstagedNodes []*filetree.FileNode) error {
|
||||
if self.context().IsFiltering() {
|
||||
// When filtering, only stage visible files
|
||||
switch self.stageAllScope() {
|
||||
case stageAllVisibleFiles:
|
||||
var paths []string
|
||||
_ = root.ForEachFile(func(file *models.File) error {
|
||||
paths = append(paths, file.Path)
|
||||
return nil
|
||||
})
|
||||
return self.c.Git().WorkingTree.StageFiles(paths, nil)
|
||||
case stageAllTrackedFiles:
|
||||
return self.c.Git().WorkingTree.StageAll(true)
|
||||
default:
|
||||
return self.c.Git().WorkingTree.StageAll(false)
|
||||
}
|
||||
|
||||
onlyTrackedFiles := self.context().GetStatusFilter() == filetree.DisplayTracked
|
||||
return self.c.Git().WorkingTree.StageAll(onlyTrackedFiles)
|
||||
}
|
||||
|
||||
unstage := func(nodes []*filetree.FileNode) error {
|
||||
|
||||
Reference in new issue
Block a user