mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-17 01:42:45 +02:00
Fix flakey worktree tests
In the presentation layer, when showing branches, we'll show worktrees against branches if they're associated. But there was a race condition: if the worktree model was refreshed after the branches model, it wouldn't be used in the presentation layer when it came time to render the branches. A better solution would be to have some way of signalling that a particular context needs to be refreshed and after all the models are done being refreshed, we then refresh the contexts. This will prevent double-renders
This commit is contained in:
@ -607,6 +607,12 @@ func (self *RefreshHelper) refreshWorktrees() error {
|
|||||||
|
|
||||||
self.c.Model().Worktrees = worktrees
|
self.c.Model().Worktrees = worktrees
|
||||||
|
|
||||||
|
// need to refresh branches because the branches view shows worktrees against
|
||||||
|
// branches
|
||||||
|
if err := self.c.PostRefreshUpdate(self.c.Contexts().Branches); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return self.c.PostRefreshUpdate(self.c.Contexts().Worktrees)
|
return self.c.PostRefreshUpdate(self.c.Contexts().Worktrees)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ var DetachWorktreeFromBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
}).
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
Contains("mybranch"),
|
Contains("mybranch"),
|
||||||
Contains("newbranch").DoesNotContain("(worktree").IsSelected(),
|
Contains("newbranch").DoesNotContain("(worktree)").IsSelected(),
|
||||||
)
|
)
|
||||||
|
|
||||||
t.Views().Worktrees().
|
t.Views().Worktrees().
|
||||||
|
@ -46,7 +46,7 @@ var RemoveWorktreeFromBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
}).
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
Contains("mybranch"),
|
Contains("mybranch"),
|
||||||
Contains("newbranch").DoesNotContain("(worktree").IsSelected(),
|
Contains("newbranch").DoesNotContain("(worktree)").IsSelected(),
|
||||||
)
|
)
|
||||||
|
|
||||||
t.Views().Worktrees().
|
t.Views().Worktrees().
|
||||||
|
Reference in New Issue
Block a user