mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-29 22:48:24 +02:00
Some code cleanups to the "discard file changes from commit" feature (#4679)
- **PR Description** I ran into these issues while reading the code.
This commit is contained in:
@@ -313,19 +313,13 @@ func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileN
|
|||||||
// Reset the current patch if there is one.
|
// Reset the current patch if there is one.
|
||||||
if self.c.Git().Patch.PatchBuilder.Active() {
|
if self.c.Git().Patch.PatchBuilder.Active() {
|
||||||
self.c.Git().Patch.PatchBuilder.Reset()
|
self.c.Git().Patch.PatchBuilder.Reset()
|
||||||
if err := self.c.Refresh(types.RefreshOptions{Mode: types.BLOCK_UI}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, node := range selectedNodes {
|
for _, node := range selectedNodes {
|
||||||
err := node.ForEachFile(func(file *models.CommitFile) error {
|
_ = node.ForEachFile(func(file *models.CommitFile) error {
|
||||||
filePaths = append(filePaths, file.GetPath())
|
filePaths = append(filePaths, file.GetPath())
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err := self.c.Git().Rebase.DiscardOldFileChanges(self.c.Model().Commits, self.c.Contexts().LocalCommits.GetSelectedLineIdx(), filePaths)
|
err := self.c.Git().Rebase.DiscardOldFileChanges(self.c.Model().Commits, self.c.Contexts().LocalCommits.GetSelectedLineIdx(), filePaths)
|
||||||
@@ -336,7 +330,8 @@ func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileN
|
|||||||
if self.context().RangeSelectEnabled() {
|
if self.context().RangeSelectEnabled() {
|
||||||
self.context().GetList().CancelRangeSelect()
|
self.context().GetList().CancelRangeSelect()
|
||||||
}
|
}
|
||||||
return self.c.Refresh(types.RefreshOptions{Mode: types.SYNC})
|
|
||||||
|
return nil
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user