1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-03 00:57:52 +02:00
Commit Graph

4866 Commits

Author SHA1 Message Date
d30eef69b1 Use double dash for disambuating path in editor templates 2023-07-30 18:35:36 +10:00
91909331b5 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-30 18:35:36 +10:00
f31e213edc rename files 2023-07-30 18:35:36 +10:00
7b302d8c29 Write unit tests with the help of afero
Afero is a package that lets you mock out a filesystem with an in-memory filesystem.
It allows us to easily create the files required for a given test without worrying about
a cleanup step or different tests tripping on eachother when run in parallel.

Later on I'll standardise on using afero over the vanilla os package
2023-07-30 18:35:36 +10:00
a1fae41051 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-30 18:35:24 +10:00
b16bb409fc 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-30 18:35:24 +10:00
a77d24fdc6 Add section in integration readme about testing against old git versions 2023-07-30 18:35:24 +10:00
eecf07cd12 Add more i18n for worktrees 2023-07-30 18:35:24 +10:00
06be88aef7 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-30 18:35:24 +10:00
4c5b1574f1 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-30 18:35:24 +10:00
de57cfd6ff 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-30 18:35:24 +10:00
2b24c15938 Add test for opening lazygit in the worktree of a bare repo 2023-07-30 18:35:23 +10:00
e874f94cf8 Remove dead function 2023-07-30 18:35:23 +10:00
0a410141ae Fix test by making branches appear deterministically
This fixes pkg/integration/tests/worktree/rebase.go which was failing on old git versions due to a difference in
order of branches that don't have recency values
2023-07-30 18:35:23 +10:00
e356b29b4a Allow entering a submodule by pressing space 2023-07-30 18:35:23 +10:00
bc4ce26cef Allow entering a worktree by pressing enter 2023-07-30 18:35:23 +10:00
ae66f720f5 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-30 18:35:23 +10:00
9c15ba0c0b Add test for retained context focus when switching worktrees 2023-07-30 18:35:23 +10:00
b3060065d9 Support fastforwarding worktree 2023-07-30 18:35:23 +10:00
a313b16704 Add more worktree tests 2023-07-30 18:35:23 +10:00
b93b9dae88 Add worktree tests for removing/detaching 2023-07-30 18:35:23 +10:00
277142fc4b Add worktree integration tests 2023-07-30 18:35:23 +10:00
18a508b29c Update cheatsheets 2023-07-30 18:35:23 +10:00
cdfad864ae 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-30 18:35:23 +10:00
fb4453c18a Fix unit tests 2023-07-30 18:35:23 +10:00
b5ff55e538 Show loader when switching worktrees 2023-07-30 18:35:23 +10:00
81a9133261 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-30 18:35:23 +10:00
ca6f9c4155 Fix tests
Going and fixing up some submodule tests which were broken by bad assumptions with worktree code
2023-07-30 18:35:23 +10:00
7569180cac Fix tests
We now change directories to the repo on startup so we don't need to determine the test path in some special way
2023-07-30 18:35:23 +10:00
eeec373728 Safer fetching of linked worktree paths 2023-07-30 18:35:23 +10:00
0604e43813 Move worktrees tab to files window 2023-07-30 18:35:23 +10:00
27ade502ee Change directory to worktree if given as an argument
Previously we used an env var for this and it's not clear to me how that worked but
with this PR current directory = worktree directory
2023-07-30 18:35:23 +10:00
3a7468ecac Support opening worktree in editor 2023-07-30 18:35:23 +10:00
7b05dacb98 Properly render worktrees in files panel 2023-07-30 18:35:22 +10:00
b73efb2c22 Better logic for knowing which repo we're in 2023-07-30 18:35:22 +10:00
a06a5cadee Only show worktree in status panel if not the main worktree and worktrees are supported 2023-07-30 18:35:22 +10:00
3cd2d6fa5c Hide worktree functionality on old git versions 2023-07-30 18:35:22 +10:00
ec839e9e96 Associate branches with worktrees even when mid-rebase 2023-07-30 18:35:22 +10:00
6f2f9f6677 Assume that the base of a worktree can be checked out 2023-07-30 18:35:22 +10:00
2082fdf84a i18n for worktrees 2023-07-30 18:35:22 +10:00
894485190b Don't quit on error 2023-07-30 18:35:22 +10:00
87b2455dbb 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-30 18:35:22 +10:00
2e68967e02 Show base ref suggestions when creating worktree 2023-07-30 18:35:22 +10:00
71422a8549 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-30 18:35:22 +10:00
9c69a5df69 Checkout worktree when creating from worktree view 2023-07-30 18:35:22 +10:00
9b24995990 Use 'M' for months in branches panel 2023-07-30 18:35:22 +10:00
142f06357f Fix filtering logic in worktrees view 2023-07-30 18:35:22 +10:00
18ea68c23a Support creating worktrees from refs 2023-07-30 18:35:22 +10:00
4b2622d93b Fix wording 2023-07-30 18:35:22 +10:00
ae0193698e Log when directory is changed 2023-07-30 18:35:22 +10:00