Commit graph

1919 commits

Author SHA1 Message Date
Jesse Duffield 201ec5307f 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
2023-07-29 17:36:18 +10:00
Jesse Duffield 72ec7922ac Fix bug where worktree view would take over window upon switching branches
When switching worktrees (which we can now do via the branch view) we re-layout the windows and their views.
We had the worktree view ahead of the file view based on the Flatten() method in context.go, because it used
to be associated with the branches panel.
2023-07-29 17:36:18 +10:00
Jesse Duffield c9a19f0fbc Use forward-slashes on windows
We want to be using forward slashes everywhere internally, so if we get a path from windows
we should immediately convert it to use forward slashes.

I'm leaving out the recent repos list because that would require a migration
2023-07-29 17:36:18 +10:00
Jesse Duffield 0e91a2f16e Add more i18n for worktrees 2023-07-29 17:36:18 +10:00
Jesse Duffield 693048eb29 Use fields rather than methods on worktrees
I would prefer to use methods to keep things immutable but I'd rather be consistent with the other
models and update them all at once
2023-07-29 17:36:18 +10:00
Jesse Duffield 873a68949e Centralise logic for obtaining repo paths
There are quite a few paths you might want to get e.g. the repo's path, the worktree's path,
the repo's git dir path, the worktree's git dir path. I want these all obtained once and
then used when needed rather than having to have IO whenever we need them. This is not so
much about reducing time spent on IO as it is about not having to care about errors every time
we want a path.
2023-07-29 17:36:18 +10:00
Jesse Duffield f8c18d074a Remove IO logic from presentation code for worktrees
We're doing all the IO in our workers loader method so that we don't need to do any
in our presentation code
2023-07-29 17:36:18 +10:00
Jesse Duffield d599511c14 Remove dead function 2023-07-29 17:36:18 +10:00
Jesse Duffield 30cf274874 Allow entering a submodule by pressing space 2023-07-29 17:36:18 +10:00
Jesse Duffield 10287c0dc3 Allow entering a worktree by pressing enter 2023-07-29 17:36:18 +10:00
Jesse Duffield 939c573907 Update repo switch logic
We now always re-use the state of the repo if we're returning to it, and we always reset the windows to their default tabs.

We reset to default tabs because it's easy to implement. If people want to:
* have tab states be retained when switching
* have tab states specific to the current repo retained when switching back

Then we'll need to revisit this
2023-07-29 17:36:18 +10:00
Jesse Duffield 4a2c21bc10 Support fastforwarding worktree 2023-07-29 17:36:18 +10:00
Jesse Duffield df78ffd081 Add more worktree tests 2023-07-29 17:36:18 +10:00
Jesse Duffield 71070827f2 Add worktree integration tests 2023-07-29 17:36:18 +10:00
Jesse Duffield fb73bb7e25 Update cheatsheets 2023-07-29 17:36:18 +10:00
Jesse Duffield e782b77475 Remove worktree version guards
Our min required git version is 2.20 so there's no need to add guards
for worktrees because they were added in 2.5
2023-07-29 17:36:18 +10:00
Jesse Duffield d764f35c5d Fix unit tests 2023-07-29 17:36:18 +10:00
Jesse Duffield b06f938e00 Show loader when switching worktrees 2023-07-29 17:36:18 +10:00
Jesse Duffield ca0b966f44 Support older versions of git when fetching worktrees
Older versions of git don't support the -z flag in `git worktree list`.
So we're using newlines.

Also, we're not raising an error upon error because that triggers another refresh,
which gets us into an infinite loop
2023-07-29 17:36:18 +10:00
Jesse Duffield faa3a612eb Move worktrees tab to files window 2023-07-29 17:36:18 +10:00
Jesse Duffield b79d19e0a7 Support opening worktree in editor 2023-07-29 17:36:18 +10:00
Jesse Duffield 0cef35324f Properly render worktrees in files panel 2023-07-29 17:36:18 +10:00
Jesse Duffield 1638354474 Better logic for knowing which repo we're in 2023-07-29 17:36:18 +10:00
Jesse Duffield 96e41fa985 Only show worktree in status panel if not the main worktree and worktrees are supported 2023-07-29 17:36:18 +10:00
Jesse Duffield 4c1d706a85 Hide worktree functionality on old git versions 2023-07-29 17:36:18 +10:00
Jesse Duffield b6d5542b35 Associate branches with worktrees even when mid-rebase 2023-07-29 17:36:18 +10:00
Jesse Duffield 72d7b91640 Assume that the base of a worktree can be checked out 2023-07-29 17:36:18 +10:00
Jesse Duffield 32ceeaa43f i18n for worktrees 2023-07-29 17:36:18 +10:00
Jesse Duffield 82da8d7586 Don't quit on error 2023-07-29 17:36:17 +10:00
Jesse Duffield 096b8a19c5 Allow opening worktree in editor
This does the job but I think we need yet another editor command for opening a directory in a new window.
2023-07-29 17:36:17 +10:00
Jesse Duffield 8f51c80d76 Show base ref suggestions when creating worktree 2023-07-29 17:36:17 +10:00
Jesse Duffield 33fc54d6e2 Refresh work trees when discarding file changes
We do this because we may be deleting a worktree folder so we'll need to show that in the worktrees view
2023-07-29 17:36:17 +10:00
Jesse Duffield c8dcd002e2 Checkout worktree when creating from worktree view 2023-07-29 17:36:17 +10:00
Jesse Duffield e2cef55f94 Fix filtering logic in worktrees view 2023-07-29 17:36:17 +10:00
Jesse Duffield 500c0eafb9 Support creating worktrees from refs 2023-07-29 17:36:17 +10:00
Jesse Duffield e0c8a56db5 Fix wording 2023-07-29 17:36:17 +10:00
Jesse Duffield 002e4eedf5 Log when directory is changed 2023-07-29 17:36:17 +10:00
Jesse Duffield a991525391 Handle deleting branch attached to worktree 2023-07-29 17:36:17 +10:00
Jesse Duffield fd854fb7f7 Don't touch repo stack when switching worktrees
We shouldn't touch this cos we're doing a lateral move
2023-07-29 17:36:17 +10:00
Jesse Duffield 64711dfc2f Move status panel presentation logic into presentation package 2023-07-29 17:36:17 +10:00
Jesse Duffield 0776ae41d3 Land in the same panel when switching to a worktree 2023-07-29 17:36:17 +10:00
Jesse Duffield 9eb9ce88b3 Prompt to switch to worktree when branch is checked out by other worktree 2023-07-29 17:36:17 +10:00
Jesse Duffield 7af9715a1b Use git lingo 2023-07-29 17:36:17 +10:00
Jesse Duffield dbd32f63dd Improve name handling 2023-07-29 17:36:17 +10:00
Jesse Duffield 72c856ac13 Refactor 2023-07-29 17:36:17 +10:00
Jesse Duffield 4c471dff83 Alert when attempting to enter the current worktree 2023-07-29 17:36:17 +10:00
Jesse Duffield c1ea17b66f Remove comment 2023-07-29 17:36:17 +10:00
Joel Baranick b22f936522 Address PR comments 2023-07-29 17:36:17 +10:00
Joel Baranick 53e408f156 Basic support for adding a worktree 2023-07-29 17:36:17 +10:00
Joel Baranick 46bb9bb60b Put all worktree i18n strings together
Use tabwriter to align worktree panel contents
2023-07-29 17:36:17 +10:00