Skip to content

Commit 2b1f150

Browse files
authored
Some code cleanups to the "discard file changes from commit" feature (#4679)
- **PR Description** I ran into these issues while reading the code.
2 parents 2a59702 + 5be97c6 commit 2b1f150

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

pkg/gui/controllers/commits_files_controller.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,13 @@ func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileN
313313
// Reset the current patch if there is one.
314314
if self.c.Git().Patch.PatchBuilder.Active() {
315315
self.c.Git().Patch.PatchBuilder.Reset()
316-
if err := self.c.Refresh(types.RefreshOptions{Mode: types.BLOCK_UI}); err != nil {
317-
return err
318-
}
319316
}
320317

321318
for _, node := range selectedNodes {
322-
err := node.ForEachFile(func(file *models.CommitFile) error {
319+
_ = node.ForEachFile(func(file *models.CommitFile) error {
323320
filePaths = append(filePaths, file.GetPath())
324321
return nil
325322
})
326-
if err != nil {
327-
return err
328-
}
329323
}
330324

331325
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
336330
if self.context().RangeSelectEnabled() {
337331
self.context().GetList().CancelRangeSelect()
338332
}
339-
return self.c.Refresh(types.RefreshOptions{Mode: types.SYNC})
333+
334+
return nil
340335
})
341336
},
342337
})

0 commit comments

Comments
 (0)