1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-04 03:48:07 +02:00

Do not perform IO work when getting disabled reason with local commits

Because we obtain disabled reasons after every action, we need to keep the code for doing so
super fast. As such, we should not be hitting the filesystem to get rebase state, instead
we should just get the cached state.

I feel like we should actually be using the cached state everywhere like we do with all
our other models if only for the sake of consistency.
This commit is contained in:
Jesse Duffield 2024-01-13 00:28:04 +11:00
parent 23a98937b4
commit ee106f9af8

View File

@ -534,7 +534,7 @@ func (self *LocalCommitsController) rebaseCommandEnabled(action todo.TodoCommand
}
if !commit.IsTODO() {
if self.c.Git().Status.WorkingTreeState() != enums.REBASE_MODE_NONE {
if self.c.Model().WorkingTreeStateAtLastCommitRefresh != enums.REBASE_MODE_NONE {
// If we are in a rebase, the only action that is allowed for
// non-todo commits is rewording the current head commit
if !(action == todo.Reword && self.isHeadCommit()) {
@ -688,7 +688,7 @@ func (self *LocalCommitsController) amendTo(commit *models.Commit) error {
}
func (self *LocalCommitsController) getDisabledReasonForAmendTo(commit *models.Commit) string {
if !self.isHeadCommit() && self.c.Git().Status.WorkingTreeState() != enums.REBASE_MODE_NONE {
if !self.isHeadCommit() && self.c.Model().WorkingTreeStateAtLastCommitRefresh != enums.REBASE_MODE_NONE {
return self.c.Tr.AlreadyRebasing
}
@ -871,7 +871,7 @@ func (self *LocalCommitsController) squashAllAboveFixupCommits(commit *models.Co
}
func (self *LocalCommitsController) getDisabledReasonForSquashAllAboveFixupCommits(commit *models.Commit) string {
if self.c.Git().Status.WorkingTreeState() != enums.REBASE_MODE_NONE {
if self.c.Model().WorkingTreeStateAtLastCommitRefresh != enums.REBASE_MODE_NONE {
return self.c.Tr.AlreadyRebasing
}
@ -880,7 +880,7 @@ func (self *LocalCommitsController) getDisabledReasonForSquashAllAboveFixupCommi
// For getting disabled reason
func (self *LocalCommitsController) notMidRebase() string {
if self.c.Git().Status.WorkingTreeState() != enums.REBASE_MODE_NONE {
if self.c.Model().WorkingTreeStateAtLastCommitRefresh != enums.REBASE_MODE_NONE {
return self.c.Tr.AlreadyRebasing
}