Commit graph

287 commits

Author SHA1 Message Date
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 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 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
Joel Baranick b10670ba44 Improve worktree panel 2023-07-29 17:36:17 +10:00
Joel Baranick f13f85de8e 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-29 17:36:17 +10:00
Joel Baranick 4a2c54e5d8 Update status to differentiate the main vs linked worktrees 2023-07-29 17:36:17 +10:00
Joel Baranick 2f156b3438 Support for deleting a worktree 2023-07-29 17:36:17 +10:00
Joel Baranick eded08bacf Initial addition of support for worktrees 2023-07-29 17:36:17 +10:00
Jesse Duffield 39b77c0fca Have staging refresh wait for files to refresh first 2023-07-29 10:20:15 +10:00
Jesse Duffield 63e5790410 Speed up refresh using concurrency and wait groups
Previously our synchronous refreshes took far longer because nothing
was happening concurrently. We now run refresh functions concurrently
and use a wait group to ensure they're all done before returning
2023-07-29 10:04:11 +10:00
Jesse Duffield 09ce430240 Log duration of refresh 2023-07-29 09:39:10 +10:00
Stefan Haller 67a7293e79 Show error when trying to open patch menu with an empty patch 2023-07-26 14:27:18 +02:00
Stefan Haller c21633b1be Prompt for commit message when moving a custom patch to a new commit 2023-07-23 13:55:48 +02:00
Jesse Duffield 7807b40322 Better tag creation UX
Previously we used a single-line prompt for a tag annotation. Now we're using the commit message
prompt.

I've had to update other uses of that prompt to allow the summary and description labels to
be passed in
2023-07-22 14:36:35 +10:00
Jesse Duffield 3cee37388c Keep track of authors across local commits and branch commits for suggestions
Previously, we would only show the authors based on local commits, but sometimes you want to set a commit author
to that of a commit on another branch. Now, so long as you've viewed the branch's commits, the author will appear
as a suggestion.
2023-07-22 10:47:04 +10:00
Jesse Duffield 87bf1dbc7f Only apply right-alignment on first column of keybindings menu
Previously we applied a right-align on the first column of _all_ menus, even though we really
only intended for it to be on the first column of the keybindings menu (that you get from pressing
'?')
2023-07-20 21:23:46 +10:00
Jesse Duffield 373f24c80f Fix crash on empty menu
When a menu is empty (e.g. due to filtering) we shouldn't crash on focus or selection
2023-07-20 21:05:52 +10: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 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 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 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 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
Jesse Duffield cd989d8ebe Fix escape logic for remote branches
The remote branches controller was using its own escape method meaning it didn't go through the flow of cancelling
an active filter. It's now using the same approach as the sub-commits and commit-files contexts: defining a parent
context to return to upon hittin escape.
2023-07-03 12:54:14 +10:00