1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-04 10:34:55 +02:00
Commit Graph

4356 Commits

Author SHA1 Message Date
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
Stefan Haller
1827380c69 Fix git stash calls for older git versions
Older git versions are pickier about parameter order: for "store", the sha
argument must come last, and for "save", the message must come last.
2023-07-10 15:09:17 +02:00
Stefan Haller
ea0baf58e6 Fix Shell.Stash() for older versions of git
Older versions need an explicit "push" subcommand for the -m option to be
recognized.
2023-07-10 15:09:17 +02:00
Stefan Haller
1d96ade0ba Remove StashWithMessage function
It's identical to Stash(), so use that.
2023-07-10 15:09:17 +02:00
Stefan Haller
82b3803164 Use -c init.defaultBranch=master to pass the desired main branch to git init
Older versions of git don't support the -b option yet. However, no version of
git complains about the -c option, even when the init.defaultBranch config is
not supported.
2023-07-10 15:09:17 +02:00
Stefan Haller
f4ada537d2 Remove mainBranch parameter from Shell.Init()
For older git versions we won't be able to support any other main branch than
"master", so hard-code that in Init.

This doesn't fix anything for older versions yet; see the next commit for that.
2023-07-10 15:09:17 +02:00
Stefan Haller
956399a1ea Add script to run integration tests 2023-07-10 15:09:17 +02:00
Jesse Duffield
057742d4af
Retry tests on CI (#2769) 2023-07-10 22:30:22 +10:00
Jesse Duffield
9c0a151dfa Retry tests on CI
Now that we are running each test 6 times on CI, the risk of flakiness
is higher. I want to fix these tests for good but it'l take time, so
we're just retrying for now
2023-07-10 22:18:22 +10:00
Stefan Haller
f9414f275d
Fix interactive rebase with git 2.25.1 and earlier (#2747) 2023-07-10 13:48:37 +02:00
Stefan Haller
cc316ab6de Fix interactive rebase with git 2.25.1 and earlier
The code in getHydratedRebasingCommits relied on the assumption that the
git-rebase-todo file contains full SHAs. This has only been true from 2.25.2 on,
before that it would contain abbreviated SHAs. Fix this by storing fullCommits
in a slice instead of a map, and using a linear search.
2023-07-10 13:42:35 +02:00
README-bot
8f00bfebce Updated README.md 2023-07-10 11:41:45 +00:00
Jesse Duffield
2dddd906f8
Track busy/idle state for integration tests (#2765) 2023-07-10 21:41:29 +10:00
Jesse Duffield
16ed3c2377 Retry on index.lock error
I don't know why we're getting index.lock errors but they're impossile to stop
anyway given that other processes can be calling git commands. So we're retrying
a few times before re-raising. To do this we need to clone the command and the current
implementation for that is best-effort.

I do worry about the maintainability of that but we'll see how it goes.

Also, I thought you'd need to clone the task (if it exists) but now I think not;
as long as you don't call done twice on it you should be fine, and you shouldn't
be done'ing a task as part of running a command: that should happen higher up.
2023-07-10 19:13:18 +10:00
Jesse Duffield
d44d164a5a Ensure background refreshes don't bunch up 2023-07-10 17:30:44 +10:00
Jesse Duffield
90613056ce Fix flakey pull_merge_conflict test
It's not clear what was happening but it seemed like we sometimes weren't
fully writing to our stdout buffer (which is used for the error message)
even though we had returned from cmd.Wait().

Not sure what the cause was but removing an unnecessary goroutine fixed it.
2023-07-10 17:12:34 +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
a0154dc525 Refactor 2023-07-10 17:12:21 +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
8964cedf27 Use mutex on cached git config
This fixes a race condition caused by a concurrent map read and write
2023-07-09 21:30:19 +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
fdee0e1497 Fix test
It's still skipped but it had an error
2023-07-09 20:57:18 +10:00
Jesse Duffield
bf7726d130 Fix race condition
We had some test flakiness involving the index.lock file which is fixed by this commit.
We shouldn't be accessing newTaskID without the mutex, although I'm surprised that this
actually fixes the issue. Surely we don't have tasks (which typically render to the main
view) which use index.lock?
2023-07-09 20:57:18 +10:00
Jesse Duffield
6282d55919 Only attempt integration tests once
I was able to get all integration tests passing 20 times in a row without any retries so I'm going to see
if we can rely on that in CI
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
c7a3b69eb9 Remove retry logic in integration tests
I want to see how we go removing all retry logic within a test. Lazygit should be trusted to tell us when it's no longer busy,
and if it that proves false we should fix the issue in the code rather than being lenient in the tests
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
631cf1e873 Bump gocui
This includes new gocui logic for tracking busy/idle program state
2023-07-08 22:26:28 +10:00
README-bot
585ea361f6 Updated README.md 2023-07-03 02:57:28 +00:00
Jesse Duffield
1a36cb9f3f
View filtering (#2680) 2023-07-03 12:57:11 +10:00
Jesse Duffield
5d982e1d70 Add mutex to filtered list to avoid concurrency issues 2023-07-03 12:54:14 +10:00
Jesse Duffield
4d734d594a Add filtering docs 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
db7b472f9a Update cheatsheets 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
Jesse Duffield
261f30f49c Add integration tests for searching/filtering 2023-07-03 12:54:14 +10:00
Jesse Duffield
7d7399a89f Support case sensitive filtering 2023-07-03 12:54:14 +10:00
Jesse Duffield
9df634f13f Color view frame differently when searching/filtering
Given that we now persist search/filter states even after a side context loses focus, we need to make it really
clear to the user that the context is currently being searched/filtered
2023-07-03 12:54:14 +10:00
Jesse Duffield
3ca1292fb4 Show filter status similar to what we show with search 2023-07-03 12:54:14 +10:00
Jesse Duffield
13c1103815 Only cancel search if main or temporary context loses focus
This is a pickle: initially I wanted it so that a filter would cancel automatically if the current context lost focus.
But there are situations where you want to retain the focus, e.g. when a popup appears, or when you view the commits
of a branch. The issue is that when you view the commits of a branch, the branches context is removed from the context
stack. Even if this were not the case, you could imagine going branches -> sub-commits -> files -> sub-commits, where
in that case branches would definitely be off the stack upon navigating to the files context.

So because I'm too lazy to find a proper solution to this problem, I'm just making it so that filters in side contexts
are retained unless explicitly cancelled.

There's another edge case this commit handles which is that if I'm in the sub-commits context via the branches context
and start a search, then navigate to the reflog context and hit enter to get to the sub-commits context again, I need
to cancel the search before I switch. Likewise with the commit files context.
2023-07-03 12:54:14 +10:00
Jesse Duffield
b8bee4de51 Scroll to top when filtering and retain selection when cancelling filter 2023-07-03 12:54:14 +10:00
Jesse Duffield
d67b209e62 Move more logic into search helper 2023-07-03 12:54:14 +10:00
Jesse Duffield
bf5871cc4f Case insensitive string comparison 2023-07-03 12:54:13 +10:00
Jesse Duffield
13326344f0 Support filtering files 2023-07-03 12:54:13 +10:00
Jesse Duffield
84870d4503 Cancel filter/search when hitting escape 2023-07-03 12:54:13 +10:00