1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-19 17:02:18 +03:00

6296 Commits

Author SHA1 Message Date
Stefan Haller
1107462c3e
Add root node in file tree (#4346)
- **PR Description**

If files at the root level of the repository have changed, there was no
way to see the combined diff of all of them. Fix this by inserting a `/`
item in this case. This is useful in repositories such as git.git, which
have all their `.c` files at root level (gasp).

If only files inside some folder have changed, the root item gets
compressed away automatically, so nothing changes for that case (which I
guess should be more common for most people).

Addresses #4331.

- **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)
* [ ] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [ ] 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))
* [ ] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
2025-03-21 08:08:09 +01:00
Stefan Haller
26459523f5 Add a root item ("/") if files at top level have changed 2025-03-21 08:04:58 +01:00
Stefan Haller
0b42cfb568 Make Node.path private
This is in preparation for changing the meaning of path in the next commit.
2025-03-20 12:31:34 +01:00
Stefan Haller
3f4cb8bdda Use Path directly instead of GetPath getter inside the filetree package 2025-03-20 12:31:34 +01:00
Stefan Haller
53090b2c45 Use GetPath accessor outside of filetree package
In preparation of making it private to the package.
2025-03-20 12:31:34 +01:00
Stefan Haller
2dfc3491bd Rename Name to Path in File and CommitFile
Name was very confusing and misleading.
2025-03-20 12:31:34 +01:00
Stefan Haller
0b5504aa98 Cleanup: make integration test assertions for files panel more specific
Assert the entire lines using Equals instead of Contains. This makes the tests a
bit easier to read, and it makes it much easier to decide how they need to be
changed when we change the layout (like we do in the last commit of this
branch).

It is true that this requires changing all these tests for any future UI
changes, but I think this is a good price to pay; those adaptions are trivial
and can be done without thinking.
2025-03-20 11:58:50 +01:00
Stefan Haller
030c2e5aef Fix postFilterTest to actually do what it says
I'm pretty sure that the check for the main view was meant to be done with the
commit selected in the commits panel, not with the first file of the commit
files view selected, so it was pressing enter too early. It's pure coincidence
that the test worked.
2025-03-20 11:58:50 +01:00
Stefan Haller
e8d3a7afec
Add a "Content of selected file" entry to the copy menu for commit files (#4341)
- **PR Description**

Some people have the need to get at the file content of a file as it was
in an earlier commit. They expect to press `e` in the commit files view
and get the file opened in the state it was in at that commit, somehow.
I explained a few times (e.g. in #3902, #4109, and #4327) that this is
not how `e` should work; so if we want this as a feature, we'd need it
as a separate command. However, it's a bit tricky to implement; if we
check out the selected file to a temp file, it's unclear when to remove
the file again. Alternatively we could use EditAndWait to open the file,
then we would block until the user closes the editor and delete the file
then. This is probably not the best user experience though, e.g. it
wouldn't allow opening two files from an older commit at once.

Instead of finding solutions to all these questions, this PR takes a
simpler route and adds a command to the "Copy to Clipboard" menu that
allows copying the entire content of a file. Users can then open a new,
empty editor buffer and paste it in, this is almost as good as opening a
temp file, but without all the questions. This was suggested in #4327.

- **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))
* [ ] 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))
* [ ] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
2025-03-20 11:54:49 +01:00
Stefan Haller
f7295a97c0 Add a "Content of selected file" entry to the copy menu for commit files
This is useful for copying the entire content of the selected file as it was at
the selected commit.

We only add it to the commit files panel; it is not needed in the files panel,
because there you can simply press "e" to edit the file.
2025-03-20 11:52:53 +01:00
Stefan Haller
357c046df2
Drop the git config cache when getting focus (#4376)
- **PR Description**

This allows changing git config values while lazygit is running (e.g. in a
different terminal tab, or even in lazygit's ":" shell prompt), and have them
take effect immediately, while still getting some benefit from caching them
while lazygit is in the foreground.

Addresses #4240.
2025-03-20 11:52:20 +01:00
Stefan Haller
3e15be576e Drop the git config cache when getting focus
This allows changing git config values while lazygit is running (e.g. in a
different terminal tab, or even in lazygit's ":" shell prompt), and have them
take effect immediately, while still getting some benefit from caching them
while lazygit is in the foreground.
2025-03-20 11:50:28 +01:00
Stefan Haller
f98ad65f46 Cleanup: remove more unnecessary type arguments
Missed these in 44097384d30d.
2025-03-20 11:50:28 +01:00
Stefan Haller
f5f246478e
Revert #4313 (Skip post-checkout hook when discarding changes) (#4407)
@jesseduffield:

> Let's revert this PR, given that, as @TimShilov says, the
post-checkout hook will receive a flag stating whether the checkout was
for a file or a branch, meaning it's within the user's power to just
update the hook script to only run on branch checkouts if desired.
2025-03-20 11:48:47 +01:00
Stefan Haller
cf27399571 Revert "Skip post-checkout hook when discarding changes"
This reverts commit 964278255b8a0a460b74e459938057002d12390e.
2025-03-20 11:41:15 +01:00
Stefan Haller
b3b8223364
Support home and end as alternatives to '<' and '>' (#4396)
- **PR Description**

Allow pressing `<home>` and `<end>` to jump to the beginning/end of
lists, in addition to the current keybindings of `<` and `>`.
2025-03-17 20:00:02 +01:00
Stefan Haller
95c5d51e64 Support home and end as alternatives to '<' and '>' 2025-03-17 19:58:01 +01:00
Stefan Haller
71c5fa9688
Commit only tracked files in tracked filter view (#4386)
- **PR Description**
When in tracked filter view, selecting a folder for staging should only
stage files that are tracked by git. Previously, it staged even
untracked files that were not in view.
All staged (even untracked) files are shown in tracked filter view.
Fixes #4245 

- **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)
* [ ] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [ ] 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))
* [ ] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc

<!--
Be sure to name your PR with an imperative e.g. 'Add worktrees view'
see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for
examples
-->
2025-03-17 19:56:53 +01:00
Partho Kunda
7a1b63182d Commit only tracked files in tracked only filter view 2025-03-17 19:51:27 +01:00
Partho Kunda
220f06052a Show staged but untracked files in tracked only filter view 2025-03-17 19:50:58 +01:00
Stefan Haller
a0dd3bec8e
Fix commitPrefix setting with empty pattern (#4381)
Before we changed the commitPrefix config to a list in #4261, we had
this bug where the defaults section in `Config.md` would erroneously
list the default for commitPrefix as

```yml
  git:
    commitPrefix:
      pattern: ""
      replace: ""
```

This was not correct, commitPrefix was a pointer, and the default for
that was nil, which is not the same.

Now, some people copied and pasted the entire defaults section into
their config files, setting the commitPrefix to an empty pattern (which
is not the same as not setting it at all). And this caused the branch
name to be filled in to the subject field for every commit; see for
example https://github.com/jesseduffield/lazygit/discussions/3632.

New users copying the defaults section into their config file in the
current version no longer have this problem because now that
commitPrefix is a list, it is no longer included in the defaults
section. However, the migration that we added in #4261 would happily
carry over those empty strings into a list entry, so people migrating
from an older version still have the broken config in their config
files.

To work around the issue, ignore commit prefix settings whose pattern is
an empty string. I can't imagine a valid reason why people would
actually want to set the pattern to an empty string, so I assume this
only comes from the broken defaults problem described above.
2025-03-12 08:17:51 +01:00
Stefan Haller
05a18edc54 Add hint to not copy the whole defaults section into the config file
I'm not mentioning *why* it's not a good idea, and I'm not sure it's important
to explain this to users. I'll say it here:
- it exposes users to potential bugs like the one described in the previous
  commit
- if we decide to change the default of an option to something "better" (like we
  did with the "show graph" setting), users don't benefit from what we think is
  an improvement for most users
2025-03-12 08:15:36 +01:00
Stefan Haller
95940ee01e Ignore commit prefixes with an empty pattern
Before we changed the commitPrefix config to a list in #4261, we had this bug
where the defaults section in Config.md would erroneously list the default for
commitPrefix as

  git:
    commitPrefix:
      pattern: ""
      replace: ""

This was not correct, commitPrefix was a pointer, and the default for that was
nil, which is not the same.

Now, some people copied and pasted the entire defaults section into their config
files, setting the commitPrefix to an empty pattern (which is not the same as
not setting it at all). And this caused the branch name to be filled in to the
subject field for every commit; see for example
https://github.com/jesseduffield/lazygit/discussions/3632.

New users copying the defaults section into their config file in the current
version no longer have this problem because now that commitPrefix is a list, it
is no longer included in the defaults section. However, the migration that we
added in #4261 would happily carry over those empty strings into a list entry,
so people migrating from an older version still have the broken config in their
config files.

To work around the issue, ignore commit prefix settings whose pattern is an
empty string. I can't imagine a valid reason why people would actually want to
set the pattern to an empty string, so I assume this only comes from the broken
defaults problem described above.
2025-03-12 08:15:36 +01:00
Jesse Duffield
c735a5e5aa
URL encode gitlab brackets to make consistent with branch names (#4336)
- **PR Description**
Some operating systems 'open' implementations do not like when some
special characters are unencoded, so they will double-encode the branch
name, which we already encode.

This particularly matters since branch names with / are common.

Fixes https://github.com/jesseduffield/lazygit/issues/4321

- **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)
* [ ] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [ ] 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))
* [ ] Docs have been updated if necessary
* [X] You've read through your own file changes for silly mistakes etc
2025-03-12 09:27:25 +11:00
Chris McDonnell
c1ca1c8f99 URL encode gitlab brackets to make consistent with branch names
Some operating systems 'open' implementations do not like
when some special characters are unencoded, so they will
double-enconde the branch name, which we already encode.

This particularly matters since branch names with / are common
2025-03-12 09:04:04 +11:00
Stefan Haller
d423d2ac3d
Add an integration test for a config with a negative refspec (#4382)
- **PR Description**

This is a sanity check to verify that lazygit has been built with a
patched version of go-git that does not error on negative refspecs.

- **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-03-11 08:35:26 +01:00
Kevin Radloff
b76b73943a Add an integration test for a config with a negative refspec 2025-03-11 08:33:41 +01:00
Stefan Haller
bf6d2a1c28
Update to go 1.24 (#4377)
- **PR Description**
Update to go 1.24. This is required to use a newer version of go-git.

- **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-03-11 08:31:32 +01:00
Kevin Radloff
be7583dd40 Update to go 1.24 2025-03-08 14:53:54 -05:00
Stefan Haller
19ac926116
Add acme editor preset (#4360)
- **PR Description**
Add editor preset for the acme editor (http://acme.cat-v.org/)

- **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-03-06 15:09:59 +01:00
rako
f989425f8c Add acme editor preset 2025-03-06 15:02:53 +01:00
Stefan Haller
0b9f320132
Fix release schedule again (#4364)
There's no way to tell cron to run a job on the first Saturday of a
month, so we tell it to run every Saturday, and manually check whether
it's the first week of the month. This is not ideal because we'll get
notifications about failed releases three times a month, but it's better
than nothing for now.
2025-03-06 11:17:40 +01:00
Stefan Haller
f7fd5217cb Fix release schedule again
There's no way to tell cron to run a job on the first Saturday of a month, so we
tell it to run every Saturday, and manually check whether it's the first week of
the month. This is not ideal because we'll get notifications about failed
releases three times a month, but it's better than nothing for now.
2025-03-06 10:04:15 +01:00
Stefan Haller
182cefcafc
Fix changing language while lazygit is running (#4361)
- **PR Description**

When changing the language in the config file while lazygit is running,
the panel titles and tab titles weren't properly updated. I noticed this
while working on #4359.

Probably not an important feature for users, because they are unlikely
to change the language all the time; but it's still nice if this isn't
broken.
2025-03-06 08:27:29 +01:00
Stefan Haller
20ab6c8cc8 Set tab titles after reloading user config
This ensures that tab titles are updated to the new language when changing the
language in the config while lazygit is running.
2025-03-06 08:24:03 +01:00
Stefan Haller
8c014641d1 Set view titles in configureViewProperties rather than createAllViews
This ensures that they are updated to the new language when changing the
language in the config while lazygit is running.
2025-03-06 08:24:03 +01:00
Stefan Haller
1213e875bb Cleanup: standardize on accessing translations via gui.c.Tr 2025-03-06 08:24:03 +01:00
Stefan Haller
26cb4060d2
Fix layout of options view for non-english languages (#4359)
- **PR Description**

The width calculations didn't take multi-byte characters into account,
so the options bar was cut off too early for these.

Fixes #4353.
2025-03-06 08:22:21 +01:00
Stefan Haller
b31607250d Fix layout of options view for non-english languages
The width calculations didn't take multi-byte characters into account.
2025-03-06 08:19:35 +01:00
Stefan Haller
6a15a5915b
Use a waiting status for rewording a non-head commit (#4343)
- **PR Description**

Rewording a commit at the beginning of a long branch can take very long;
without this change, the commit message panel would stay visible with a
blinking cursor during that time, which is very confusing.

This has the slight downside that it will say "Rebasing" in the lower
right corner until the operation is done; but we already have this problem
when doing custom patch operations, or dropping changes from a commit, so it's not
new, and we can think about how to fix all these another time.

- **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))
* [ ] 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))
* [ ] 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))
* [ ] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
2025-03-06 08:18:34 +01:00
Stefan Haller
e6d6ed4f9a Use Rewording instead of Committing when rewording the head commit
Now that we have this status, let's use it for the head case too, for
consistency.
2025-03-06 08:15:18 +01:00
Stefan Haller
c18d8af9f4 Use a WithWaitingStatus for rewording a non-head commit
Rewording a commit at the beginning of a long branch can take very long;
without this change, the commit message panel would stay visible with a blinking
cursor during that time, which is very confusing.

This has the slight downside that it will say "Rebasing" in the lower right
corner until the operation is done; but we already have this problem when doing
custom patch operations, or dropping changes from a commit, so it's not new, and
we can think about how to fix all these another time.
2025-03-06 08:15:18 +01:00
Stefan Haller
eda65cbade Avoid double Refresh when rewording the head commit
WithGpgHandling already does an async refresh when done, so there's no need to
do one here for the case of amending the head commit. On top of that,
WithGpgHandling uses WithWaitingStatus and works in the background, so the
Refresh here would come too early anyway.
2025-03-06 08:15:18 +01:00
Stefan Haller
41a7afb105 Don't call OnCommitSuccess in handleReword
All this does is clear the preserved commit message; however, we open the commit
message panel with PreserveMessage: false when rewording, so this is not
necessary.
2025-03-06 08:15:18 +01:00
Stefan Haller
ddc14ef674
Support fish when running shell command (#4350)
- **PR Description**

This should allow using custom shell functions in lazygit's : prompt.

Fixes #4342.
2025-03-06 08:14:48 +01:00
Stefan Haller
f28b6f439d Support fish when running shell command
This should allow using custom shell functions in lazygit's : prompt.
2025-03-06 08:11:32 +01:00
Stefan Haller
08751d6b60
Fix linter warnings (#4352)
- **PR Description**

Fix a few things that started to crop up in my editor recently, probably
because of an updated gopls or something (I didn't investigate more
closely).
2025-03-06 08:10:46 +01:00
Stefan Haller
44097384d3 Remove unnecessary type arguments
I'm getting warnings in my editor about these, probably because of an updated
gopls again.
2025-03-03 21:24:49 +01:00
Stefan Haller
a4d6d020c4 Remove unused functions
For some reason the //nolint:golint,unused comment no longer seems to work after
I updated gopls (I think).

But I also don't understand why we mark unused stuff with linter comments
instead of just getting rid of it.
2025-03-03 21:23:29 +01:00
Stefan Haller
1b571f9e6b
Custom commands submenus (#4324)
- **PR Description**

I want to be able to configure custom commands that I don't need very
often; I don't want these to pollute the global keybindings menu, and I
don't want to assign globally unique keybindings to them (because there
are only so many of these available, and also because I wouldn't be able
to remember them, because the commands are not used often). However, I
still want to invoke them through keybindings somehow.

I find that the perfect solution for this is to configure a menu that
contains custom commands. I can pop open the menu using only one key
that I need to remember, but I can access the individual custom commands
inside using keys that don't need to be unique with the rest of the
global keybindings.

In this PR we achieve this by adding an optional `subCommands` property
to customCommand that can be used instead of the other properties like
`command`, etc. This is an alternative approach to #4276, which added a
new top-level property for custom command menus.

Potentially closes #3799.

- **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
v0.48.0
2025-02-28 10:47:59 +01:00