1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2026-06-20 01:19:23 +02:00
Commit Graph

7177 Commits

Author SHA1 Message Date
Stefan Haller 74b1255b4b Fix the main view display after reverting a commit (#5138)
After reverting a commit, the main view would show the diff of a commit
that is not the selected one.
2025-12-23 14:59:28 +01:00
Stefan Haller a415d1b529 Fix the main view display after reverting a commit
We move the selection down by the number of commits that were reverted (to keep
the same commits selected). However, this only happens after refreshing, which
has rendered the main view with the wrong commit, so we need to render it again
after moving the selection.

There are many other callers of MoveSelection in LocalCommitsController, but all
of them happen before the refresh. Revert is special because it needs to move
the selection after refreshing, e.g. when reverting the only commit of a branch.
2025-12-23 14:55:58 +01:00
Stefan Haller 0a48f307b1 Add test expectation showing a problem with revert
After the revert, the main view shows the diff of the wrong commit.
2025-12-23 14:48:58 +01:00
Stefan Haller cf873b16d9 Prevent many hyperlinks from launching while mouse moving (#5133)
Update our gocui dependency, which brings in the fix that was made
there; see https://github.com/jesseduffield/gocui/pull/86.

(Fix by `Chris McDonnell <c.a.mcdonn@gmail.com>`)
2025-12-22 16:28:42 +01:00
Stefan Haller 2189c3b43a Bump gocui
This brings in the fix "Prevent many hyperlinks from launching while mouse
moving".

Co-authored-by: Chris McDonnell <c.a.mcdonn@gmail.com>
2025-12-22 16:22:36 +01:00
Stefan Haller e7b69bcf24 Support custom keybindings in custom command menu prompts (#5129)
## Summary
resolves: #3626

This adds support for keybindings on menu options.

### Example Usage:
```yml
customCommands:
  - key: 'e'
    context: 'files'
    command: 'echo {{.Form.Choice | quote}} > result.txt'
    prompts:
      - type: 'menu'
        title: 'Choose an option'
        key: 'Choice'
        options:
          - value: 'foo'
            description: 'FOO'
            key: 'f'
          - value: 'bar'
            description: 'BAR'
            key: 'b'
```

### Please check if the PR fulfills these requirements

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [x] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [x] If a new UserConfig entry was added, make sure it can be
hot-reloaded (see
[here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig))
* [x] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
2025-12-22 14:24:29 +01:00
Karl Wikström 62913ee25d feat: support custom keybinds in custom command prompt menus 2025-12-22 13:43:52 +01:00
Stefan Haller 262e7f4e79 Change keybinding of "keep" item in Merge Conflict menu back to 'k' (#5132)
Now that we can use 'k' as a menu item binding (this was fixed in
#5131), use it for the "keep" entry in the merge menu. I don't think
this will be a problem for people's muscle memory, given that this menu
is not encountered every day; and it's simply the better keybinding.

This reverts commit b32b55201e.
2025-12-22 09:51:26 +01:00
Stefan Haller 6043eb52db Revert "Update resolve conflict using p instead of k"
Now that we can use 'k' as a menu item binding (this was fixed in #5131), use it
for the "keep" entry in the merge menu. I don't think this will be a problem for
people's muscle memory, given that this menu is not encountered every day; and
it's simply the better keybinding.

This reverts commit b32b55201e.
2025-12-22 09:49:04 +01:00
Stefan Haller 70fe7bd1b4 Allow using 'j', 'k', 'H', or 'L' as keybindings in custom command menus (#5131)
Previously they would be shown as keybindings in the menu, but they
didn't work because their builtin functionality (select next/prev line,
scroll view left/right) would take precedence.

This will allow us to revert #4934; doing that in a separate PR, see
#5132.
2025-12-22 09:48:38 +01:00
Stefan Haller 344d3866a6 Make menu keybindings take precedence over builtin ones, except for confirm/esc
This makes it possible to use 'j', 'k', 'H' or 'L' as menu item keybindings.
2025-12-22 09:37:06 +01:00
Stefan Haller f996e47199 Rename KeepConfirmKeybindings to KeepConflictingKeybindings
After the change in the previous commit this expresses better what it is about.
2025-12-22 09:37:06 +01:00
Stefan Haller 7e3b24d496 In menus, remove not just the confirm binding, but also esc and up/down
This is not really super important because we are very unlikely to assign a key
such as esc or up/down to a menu item. However, users might do this in a custom
commands menu, and in that case it is important that the builtin keys still
work; or they might remap those builtin commands to other keys, in which case
they might conflict with single-letter keys in normal menus.
2025-12-22 09:37:06 +01:00
Stefan Haller e19544a42b Add a test that demonstrates problems with custom menu keybindings
The test shows two problems: a <down> keybinding is not removed from a menu item
(the 'y' binding is removed though, which is correct), and keybindings such as
'j' and 'H' don't work. We will fix both of these separately in the following
commits.
2025-12-22 09:37:06 +01:00
Stefan Haller b7a24c8298 feat: add Codeberg as a supported git hosting service (#5130)
Thank you for an awesome tool. I wanted to add support for codeberg.
Tested locally that opening pull-request works

### PR Description

Codeberg is a Gitea-based git hosting service that uses the same URL
patterns for pull requests and commits but differs on its hostname
2025-12-21 14:13:20 +01:00
Yadi Abdalhalim 24e9197be2 feat: add Codeberg as a supported git hosting service
Codeberg is a Gitea-based git hosting service that uses the same URL
patterns for pull requests and commits. This adds native support so
users don't need to manually configure it.
2025-12-21 14:10:59 +01:00
Stefan Haller 3201695658 feat: add keys for command log menu items (#5096) 2025-12-14 17:14:50 +01:00
Peter Cardenas a41bd6a255 feat: add keys for command log menu items 2025-12-14 17:12:47 +01:00
Stefan Haller 8651c46e14 Fix small issues with the Breaking Changes texts (#5114) 2025-12-11 21:13:30 +01:00
Stefan Haller 46c095cc29 Add a missing quote 2025-12-11 21:10:11 +01:00
Stefan Haller 9aa268c1f4 Cleanup: use spaces instead of tab 2025-12-11 21:09:57 +01:00
Stefan Haller 6600adf671 Remove confirmation for opening the merge tool (#5094)
The confirmation used to make sense back when the Open MergeTool command
was its own top-level command; however, that command was changed in
#4889 to open a menu instead, and Open MergeTool is now just a submenu
entry in that menu, so it no longer needs a confirmation.

Fixes #5093.
2025-12-08 09:48:58 +01:00
Stefan Haller f6cba966d0 Remove confirmation for opening the merge tool
The confirmation used to make sense back when the Open MergeTool command was its
own top-level command; however, that command was changed in 703f053a7e to open a
menu instead, and Open MergeTool is now just a submenu entry in that menu, so it
no longer needs a confirmation.
2025-12-07 20:55:25 +01:00
Stefan Haller 17d03ec8cb Update docs and schema for release (#5091) v0.57.0 2025-12-06 13:58:23 +01:00
Stefan Haller da4494fb06 Update docs and schema for release 2025-12-06 13:49:02 +01:00
Stefan Haller 8ced11b5ae README.md: Update Sponsors (#5055)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action
2025-12-06 13:48:26 +01:00
github-actions[bot] d4c0c499b2 README.md: Update Sponsors 2025-12-06 12:30:25 +00:00
Stefan Haller 17c6a895b4 Update translations from Crowdin (#5090) 2025-12-06 13:30:13 +01:00
Stefan Haller 6fbf64b70e Update translations from Crowdin 2025-12-06 13:28:19 +01:00
Stefan Haller cc96d8cede Fix to support creating MRs for repositories cloned with SSH alias (#5082)
### PR Description

Use case: some repositories are cloned with a full SSH alias (without a
user). E.g. in `.ssh/config` you have

```
Host gitlab
    HostName gitlab.com
    User git
    IdentityFile ...
```

and then you clone with `git clone gitlab:foo/bar`

According to the docs, you can add a service to `config.yaml` and it
should work:

```yaml
services:
  gitlab: 'gitlab:gitlab.com'
```

But currently it doesn't because lazygit expects all remote URLs to have
a user. This can be fixed by the user by changing the URL to e.g.
`git@gitlab:foo/bar`, but it breaks the user flow and is quite
unexpected.

This PR changes `defaultUrlRegexStrings` and makes the `user@` part of
the remote URL optional. Fixes the issue for Github and Gitlab which use
the default regexes.
2025-12-06 11:58:44 +01:00
Mikhail Akimov d6ff7f152d Fix to support creating merge requests for Gitlab/Github repositories cloned with an SSH config alias 2025-12-06 11:52:55 +01:00
Stefan Haller 0fc8cb35a8 chore: fix function name in comment (#4481) 2025-12-06 11:45:51 +01:00
riyueguang 13b4e16e6a chore: fix function name in comment
Signed-off-by: riyueguang <rustruby@outlook.com>
2025-12-06 18:28:58 +08:00
Stefan Haller 06426b2107 refactor: use strings.Builder and strings.Repeat to simplify code (#5068)
### PR Description

strings.Builder has fewer memory allocations and better performance.
More info: [golang/go#75190](https://github.com/golang/go/issues/75190)
2025-12-03 18:39:11 +01:00
boqishan 89a0542a97 refactor: use strings.Builder and strings.Repeat to simplify code
Signed-off-by: boqishan <boqishan@126.com>
2025-12-03 18:34:21 +01:00
Stefan Haller 8396747cf1 Band-aid fix for rare crashes when refreshing files (#5074)
Users have filed issues with crash reports that seem to indicate that
the FileTreeViewModel gets swapped out (by a refresh) while a call to
itemsSelected is in progress, iterating over the previous items. Guard
against this by locking the mutex that we already have for this for the
duration of the call.

I don't have a good way of testing whether the fix helps, because the
crashes only occurred very infrequently. Let's just see if the crash
reports stop coming in after we ship this.

Note also that this is only the minimal fix for the crashes that were
reported. Theoretically, the same problem could happen for a key handler
itself, but we never saw reports about that, so we don't bother doing
anything about that yet.

Note also that long-term I envision a different solution to this class
of problems (discussed in
https://github.com/jesseduffield/lazygit/issues/2974), that's why I want
to avoid locking mutexes more than necessary now.

Fixes #3646 
Fixes #4154
Fixes #4301
Fixes #5070
2025-12-03 08:10:13 +01:00
Stefan Haller d274474c61 Band-aid fix for rare crashes when refreshing files
Users have filed issues with crash reports that seem to indicate that the
FileTreeViewModel gets swapped out (by a refresh) while a call to itemsSelected
is in progress, iterating over the previous items. Guard against this by locking
the mutex that we already have for this for the duration of the call.

I don't have a good way of testing whether the fix helps, because the crashes
only occurred very infrequently. Let's just see if the crash reports stop coming
in after we ship this.

Note also that this is only the minimal fix for the crashes that were reported.
Theoretically, the same problem could happen for a key handler itself, but we
never saw reports about that, so we don't bother doing anything about that yet.

Note also that long-term I envision a different solution to this class of
problems (discussed in https://github.com/jesseduffield/lazygit/issues/2974),
that's why I want to avoid locking mutexes more than necessary now.
2025-12-03 08:08:21 +01:00
Stefan Haller d1d2bb23b6 Show fixup base commits in correct order in ctrl-f error message (#5073)
If the ctrl-f command ("Find base commit for fixup") finds multiple
candidates, it lists them all in an error message. Previously they were
listed in random order in the error message, which can be confusing;
it's nicer to see them in the same order in which they appear in the
commit log.

Fixes #5071.
2025-11-30 14:08:22 +01:00
Stefan Haller 26453b26cf Remove unused function GetHashesAndCommitMessagesFirstLine 2025-11-30 14:06:31 +01:00
Stefan Haller e2b3601c57 Fix order of fixup base commits shown in ctrl-f error message 2025-11-30 14:06:31 +01:00
Stefan Haller c16b4b1d2e Make find_base_commit_for_fixup tests more specific
We want to test the order in which the commits are listed in the error message.
For one of the tests the order is already as we want it, but for the other it's
not (we want them to show up in log order). We'll fix this in the next commit.
2025-11-30 14:06:31 +01:00
Stefan Haller 28cd1c2df4 Don't use "HEADLESS" environment variable for running tests (#5064)
It is a bit generic, it seems that users sometimes set it for other
reasons (see
https://github.com/jesseduffield/lazygit/issues/5030#issuecomment-3541000735),
and then they are confused why they don't see anything. Use a more
specific name instead.
2025-11-28 12:09:17 +01:00
Stefan Haller 9334bf0333 Don't use "HEADLESS" environment variable for running tests
It is a bit generic, it seems that users sometimes set it for other reasons, and
then they are confused why they don't see anything. Use a more specific name
instead.
2025-11-28 12:06:42 +01:00
Stefan Haller e3ea666352 Fix deleting a remote tag when a remote branch with the same name exists, or vice versa (#5075)
Nothing to add to the PR title here.

Fixes #5072.
2025-11-28 12:06:03 +01:00
Stefan Haller 11a6a73be5 Fix deleting a remote tag when a remote branch with the same name exists 2025-11-27 19:52:18 +01:00
Stefan Haller 7809823064 Fix deleting a remote branch when a remote tag with the same name exists 2025-11-27 19:51:24 +01:00
Stefan Haller 4d4b143cc7 Add tests demonstrating the problem
Trying to delete a remote tag when a remote branch with the same name exists
results in an error, and vice versa.
2025-11-27 19:51:13 +01:00
Stefan Haller 19a4454599 Cleanup: remove unnecessary keypress
Seems to be a copy/paste error from another test.
2025-11-27 19:32:22 +01:00
Stefan Haller b57be9ebe4 Fix and speed up the file list for the "Enter path to filter by" feature (#5056)
The file suggestions list that appears when you choose "Enter path to
filter by" from the Filtering menu was previously implemented by walking
the file system to collect all files, and then filter out the ones that
are git-ignored. This approach had several problems:
- for certain .gitignore configurations there was a bug in the code that
filters out ignored files, causing the list to be empty. See
https://github.com/jesseduffield/lazygit/issues/2642#issuecomment-3554117172
for details.
- the list included files from submodules. While at first glance this
might sound useful, it doesn't work: choosing a file from the list shows
an empty log. Lazygit would have to switch to the submodule first to
show the log, which would be unexpected in the context of the Filtering
dialog, so it's better to not show these files, and require the user to
enter a submodule explicitly before they can filter on a file in it.
- it was rather slow.

This PR improves all these by using a call to `git ls-files` to list the
repositories files.

Here are some rough hand-timed measurements (from opening the Filtering
dialog until the file list shows) for various repos:

|                             | before | after          |
|:--------------------------- | ------:| -------------- |
| lazygit (3'200 files)       |    ~1s | not measurable |
| my work repo (90'000 files) |     7s | <1s            |
| llvm (150'000 files)        |     5s | ~1s            |

Fixes #2642
2025-11-21 07:59:58 +01:00
Stefan Haller b06c2bb025 Remove the 'minimal' dependency which we no longer need 2025-11-21 07:57:56 +01:00