1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
Commit Graph

4577 Commits

Author SHA1 Message Date
Stefan Haller
39f3f150ed Fix crash when a background fetch prompts for credentials
This happens consistently for my when I close my MacBook's lid. It seems that
MacOS locks the user's keychain in this case, and since I have my keychain
provide the pass phrases for my ssh keys, fetching fails because it tries to
prompt me for a pass phrase.

This all worked correctly already, we have the FailOnCredentialRequest()
mechanism specifically for this situation, so all is great. The only problem was
that it was trying to pause the ongoing task while prompting the user for input;
but the task is nil for a background fetch (and should be).
2023-07-18 18:53:35 +02:00
Stefan Haller
7e9f669421
Show all tags in commits panel (#2776) 2023-07-15 13:11:44 +02:00
Stefan Haller
6b769fb138 Fix populating the Commit.Tags field
We now store all tags in this field if there are several.
2023-07-15 13:07:02 +02:00
Stefan Haller
cc835a813e Extend commit_loader test to show how the Tags field is populated
It shows that right now, we take only the first tag if there are multiple.
Judging from how the code is written, I'm not sure this was intentional.
2023-07-15 13:07:02 +02:00
Stefan Haller
6103a4d13c
Fix potentially wrong help text in commit message panel (#2777) 2023-07-15 13:06:16 +02: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
README-bot
bfcff3222c Updated README.md 2023-07-15 06:44:44 +00:00
Jesse Duffield
5adea789d0
Add test for cmd obj cloning (#2780) 2023-07-15 16:44:30 +10:00
Jesse Duffield
78bbdca757 Add test for cmd obj cloning 2023-07-15 11:05:43 +10:00
Stefan Haller
5cb82a49f8
config: rely on .gitconfig for verbose commit messages (#2664)
As discussed in https://github.com/jesseduffield/lazygit/pull/2599, it
makes more sense to have the user specify whether they want verbose
commits from their own git config, rather than lazygit config.

This means that we can remove all the code (including test coverage)
associated with the custom verbose flag, and lazygit will just inherit
the .gitconfig settings automatically.

---

Tested visually locally, as well as running the tests that all pass.
2023-07-14 08:05:22 +02:00
Scott Callaway
9617737352 config: rely on .gitconfig for verbose commit messages
As discussed in https://github.com/jesseduffield/lazygit/pull/2599, it
makes more sense to have the user specify whether they want verbose
commits from their own git config, rather than lazygit config.

This means that we can remove all the code (including test coverage)
associated with the custom verbose flag, and lazygit will just inherit
the .gitconfig settings automatically.
2023-07-14 07:56:09 +02:00
Jesse Duffield
a251f6ad6c
Allow checking for merge conflicts after running a custom command (#2773) 2023-07-13 18:43:25 +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
README-bot
1ded318666 Updated README.md 2023-07-11 07:22:08 +00:00
Jesse Duffield
e15a99e626
Do not quote initial branch arg when creating repo (#2771) 2023-07-11 17:21:55 +10:00
Jesse Duffield
d4eae73a68 Do not quote initial branch arg when creating repo
Also, we shouldn't pass the initial branch arg if it's empty.
2023-07-11 17:18:58 +10:00
Stefan Haller
5ba1eb2785
Run integration tests with all supported git versions (#2754)
Run integration tests with various different git versions, more or less
randomly picked from our range of supported versions. Based on
@Ryooooooga's work in #2459, but also restructured a bit.

All tests pass for all git versions, but only after cherry-picking
#2747.

I decided to go with @Ryooooooga's approach and do it without using
docker. I also didn't use docker locally; to reproduce the various
failures that I had to fix, I simply installed the respective git
versions locally and used something like
`PATH=~/git-versions/2.25.1/bin:$PATH
./scripts/run_integration_tests.sh`.
2023-07-10 15:13:43 +02:00
Stefan Haller
d71f5d951e Run integration tests with various git versions
We pick a few interesting ones in the range of supported versions.

Based on work by Ryooooooga <eial5q265e5@gmail.com>.
2023-07-10 15:09:27 +02:00
Stefan Haller
adce8ad398 Update checkout and cache action versions 2023-07-10 15:09:17 +02:00
Stefan Haller
62ab41c310 Fix pull rebase tests
It seems that older git versions would drop empty commits when rebasing. Since
this aspect is not relevant to what we're testing here, fix this by simply
avoiding empty commits in these tests.
2023-07-10 15:09:17 +02:00
Ryooooooga
85f7aa9d7b Fix conflict test
The test apply_in_reverse_with_conflict.go fails in git versions 2.30.8 and
earlier. Apparently the output "Applied patch to 'file2' cleanly" was only added
more recently. It's not essential that we check this output.
2023-07-10 15:09:17 +02: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
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