Commit graph

1883 commits

Author SHA1 Message Date
Jesse Duffield e57f6ff9c5 Better logic for knowing which repo we're in 2023-07-17 14:38:08 +10:00
Jesse Duffield a748294bc1 Only show worktree in status panel if not the main worktree and worktrees are supported 2023-07-17 14:10:32 +10:00
Jesse Duffield eb099c13c7 Hide worktree functionality on old git versions 2023-07-17 14:10:32 +10:00
Jesse Duffield 2ff12e6820 Associate branches with worktrees even when mid-rebase 2023-07-17 13:43:10 +10:00
Jesse Duffield a8aafbc6af Assume that the base of a worktree can be checked out 2023-07-17 09:48:37 +10:00
Jesse Duffield 67e6e4e8fd i18n for worktrees 2023-07-17 09:46:14 +10:00
Jesse Duffield a8d99a8ee7 Don't quit on error 2023-07-17 09:13:16 +10:00
Jesse Duffield 223143c834 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-16 20:44:35 +10:00
Jesse Duffield f6973cf7e4 Show base ref suggestions when creating worktree 2023-07-16 20:38:22 +10:00
Jesse Duffield e1e7e9185e 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-16 20:35:04 +10:00
Jesse Duffield 48d161dd1c Checkout worktree when creating from worktree view 2023-07-16 20:35:04 +10:00
Jesse Duffield 4d1352e3d0 Fix filtering logic in worktrees view 2023-07-16 20:07:04 +10:00
Jesse Duffield a7367ffcc1 Support creating worktrees from refs 2023-07-16 20:07:04 +10:00
Jesse Duffield cda40a7b75 Fix wording 2023-07-16 18:23:47 +10:00
Jesse Duffield 76c62eba7c Log when directory is changed 2023-07-16 18:23:47 +10:00
Jesse Duffield 835ca6389e Handle deleting branch attached to worktree 2023-07-16 17:59:41 +10:00
Jesse Duffield c996c29df0 Don't touch repo stack when switching worktrees
We shouldn't touch this cos we're doing a lateral move
2023-07-16 17:26:27 +10:00
Jesse Duffield dc9a6e0ea5 Move status panel presentation logic into presentation package 2023-07-16 17:15:19 +10:00
Jesse Duffield eaba9dd62d Land in the same panel when switching to a worktree 2023-07-16 14:37:49 +10:00
Jesse Duffield 5d52852df3 Prompt to switch to worktree when branch is checked out by other worktree 2023-07-16 14:14:09 +10:00
Jesse Duffield 7d4432c4b5 Use git lingo 2023-07-16 13:53:59 +10:00
Jesse Duffield a1235fa468 Improve name handling 2023-07-16 13:43:20 +10:00
Jesse Duffield 2dd2b9f5e3 Refactor 2023-07-16 12:21:43 +10:00
Jesse Duffield 3245350bab Alert when attempting to enter the current worktree 2023-07-16 11:20:22 +10:00
Jesse Duffield 6e51dd1c85 Remove comment 2023-07-16 11:16:10 +10:00
Joel Baranick 77db982774 Address PR comments 2023-07-16 11:04:39 +10:00
Joel Baranick e16f56e492 Basic support for adding a worktree 2023-07-16 10:55:56 +10:00
Joel Baranick 3055944b5d Put all worktree i18n strings together
Use tabwriter to align worktree panel contents
2023-07-16 10:53:00 +10:00
Joel Baranick 6194b17ebb Improve worktree panel 2023-07-16 10:50:25 +10:00
Joel Baranick 15ffb34474 Style missing worktree as red and display better error when trying to switch to them
Use a broken link icon for missing worktrees
2023-07-16 10:48:22 +10:00
Joel Baranick 32409dbb2f Hide worktrees in the worktree panel if they point at a non-existing filesystem location.
Remove unneeded check when filtering out branches from non-current worktrees from the branch panel.
Add link icon for linked worktrees
2023-07-16 10:32:36 +10:00
Joel Baranick 4ec960f07d Update status to differentiate the main vs linked worktrees 2023-07-16 10:29:08 +10:00
Joel Baranick a7bdc6be01 Support for deleting a worktree 2023-07-16 10:23:17 +10:00
Joel Baranick 271f894106 Initial addition of support for worktrees 2023-07-16 10:20:36 +10:00
Stefan Haller 69575dd4f3 Fix potentially wrong help text in commit message panel
It said "Press tab to toggle focus", which is wrong for people who remapped
their togglePanel key binding to something else. Print the actual key binding
instead.
2023-07-15 13:03:13 +02:00
Jesse Duffield b61ca21a84 Allow checking for merge conflicts after running a custom command
We have a use-case to rebind 'm' to the merge action in the branches panel. There's three ways to handle this:
1) For all global keybindings, define a per-panel key that invokes it
2) Give a name to all controller actions and allow them to be invoked in custom commands
3) Allow checking for merge conflicts after running a custom command so that users can add their own 'git merge' custom command
that matches the in-built action

Option 1 is hairy, Option 2 though good for users introduces new backwards compatibility issues that I don't want to do
right now, and option 3 is trivially easy to implement so that's what I'm doing.

I've put this under an 'after' key so that we can add more things later. I'm imagining other things like being able to
move the cursor to a newly added item etc.

I considered always running this hook by default but I'd rather not: it's matching on the output text and I'd rather something
like that be explicitly opted-into to avoid cases where we erroneously believe that there are conflicts.
2023-07-13 18:40:34 +10:00
Stefan Haller 30ce7c8085 Replace uses of "git stash save" with "git stash push"
Save has been deprecated for a while, push is the recommended way to save a
stash. Push has been available since 2.13, so we can use it without problems.
2023-07-10 15:09:17 +02:00
Jesse Duffield d44d164a5a Ensure background refreshes don't bunch up 2023-07-10 17:30:44 +10:00
Jesse Duffield c05a1ae711 Fix flakey misc/initial_open test
I've simplifiied the code because it was too complex for the current requirements, and this fixed the misc/initial_open
test which was occasionally failing due to a race condition around busy tasks
2023-07-10 17:12:34 +10:00
Jesse Duffield 6b9390409e Use an interface for tasks instead of a concrete struct
By using an interface for tasks we can use a fake implementation in tests with extra methods
2023-07-10 17:12:21 +10:00
Jesse Duffield 14ecc15e71 Use first class task objects instead of global counter
The global counter approach is easy to understand but it's brittle and depends on implicit behaviour that is not very discoverable.

With a global counter, if any goroutine accidentally decrements the counter twice, we'll think lazygit is idle when it's actually busy.
Likewise if a goroutine accidentally increments the counter twice we'll think lazygit is busy when it's actually idle.
With the new approach we have a map of tasks where each task can either be busy or not. We create a new task and add it to the map
when we spawn a worker goroutine (among other things) and we remove it once the task is done.

The task can also be paused and continued for situations where we switch back and forth between running a program and asking for user
input.

In order for this to work with `git push` (and other commands that require credentials) we need to obtain the task from gocui when
we create the worker goroutine, and then pass it along to the commands package to pause/continue the task as required. This is
MUCH more discoverable than the old approach which just decremented and incremented the global counter from within the commands package,
but it's at the cost of expanding some function signatures (arguably a good thing).

Likewise, whenever you want to call WithWaitingStatus or WithLoaderPanel the callback will now have access to the task for pausing/
continuing. We only need to actually make use of this functionality in a couple of places so it's a high price to pay, but I don't
know if I want to introduce a WithWaitingStatusTask and WithLoaderPanelTask function (open to suggestions).
2023-07-09 21:30:19 +10:00
Jesse Duffield 9e79ee5fe3 Add dev doc for busy/idle tracking 2023-07-09 20:57:18 +10:00
Jesse Duffield e588355f57 Add mutex for refreshing branches
We had a race condition due to refreshing branches in two different places, one which refreshed reflog commits
beforehand. The race condition meant that upon load we wouldn't see recency values (provided by the reflog commits)
against the branches
2023-07-09 20:57:18 +10:00
Jesse Duffield b19943af01 Wait for intro before doing any of our refresh functions
We were doing this already for fetching but not for refreshing files so I'm making it consistent.
2023-07-08 22:54:52 +10:00
Jesse Duffield 015a04fac6 Remove redundant waitgroup
Turns out we're just running our refresh functions one after the other which isn't ideal but we can fix that separately.
As it stands this wait group isn't doing anything.
2023-07-08 22:54:52 +10:00
Jesse Duffield 26ca41a40e Handle pending actions properly in git commands that require credentials
I don't know if this is a hack or not: we run a git command and increment the pending action
count to 1 but at some point the command requests a username or password, so we need to prompt
the user to enter that. At that point we don't want to say that there is a pending action,
so we decrement the action count before prompting the user and then re-increment it again afterward.

Given that we panic when the counter goes below zero, it's important that it's not zero
when we run the git command (should be impossible anyway).

I toyed with a different approach using channels and a long-running goroutine that
handles all commands that request credentials but it feels over-engineered compared to this
commit's approach.
2023-07-08 22:54:52 +10:00
Jesse Duffield 6c4e7ee972 Add busy count for integration tests
Integration tests need to be notified when Lazygit is idle so they can progress to the next assertion / user action.
2023-07-08 22:54:52 +10:00
Jesse Duffield 5d982e1d70 Add mutex to filtered list to avoid concurrency issues 2023-07-03 12:54:14 +10:00
Jesse Duffield b625eb5323 Differentiate between different filter modes
We can filter by path, by file status, and by text.
2023-07-03 12:54:14 +10:00
Jesse Duffield 8e46b8a275 Use searching, not filtering, in file tree views
There's more work to be done to support filtering for these views so we're sticking with searching for now
2023-07-03 12:54:14 +10:00