1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-23 22:24:51 +02:00
Commit Graph

7012 Commits

Author SHA1 Message Date
Mad Scientist
8d15d14c59 Update table of contents in README.md 2025-11-16 11:06:34 +05:00
Stefan Haller
58d2ffa1d6 Suppress output from background fetch (unless there were errors) (#5044)
The output from background fetching is noisy and pollutes the command
log. Don't show it by default, unless there were errors, in which case
it is important to see e.g. which fork was deleted.
2025-11-15 18:32:43 +01:00
Stefan Haller
f8a48b61fc Suppress output from background fetch
However, show it when there was an error. This is important for the case that a
fork that you have as a remote was deleted, in which case the command log is the
only way to get notified about that.
2025-11-15 18:27:18 +01:00
Stefan Haller
eb91a43d58 Test properties of cmdObj for Push 2025-11-15 18:25:52 +01:00
Stefan Haller
9272276247 Don't log the GetDiff command
This is used for internal purposes and shouldn't pollute the command log.
2025-11-15 18:15:24 +01:00
Stefan Haller
933573fd94 Don't allow empty input in most prompts (#5043)
Most of our prompts don't (shouldn't) allow empty input, but most
callers didn't check, and would run into cryptic errors when the user
pressed enter at an empty prompt (e.g. when creating a new branch). Now
we simply don't allow hitting enter in this case, and show an error
toast instead.

This behavior is opt-out, because there are a few cases where empty
input is supported (e.g. creating a stash).
2025-11-15 15:41:54 +01:00
Stefan Haller
95e5ed6f47 Remove TrimSpace calls that are no longer needed
The prompt code takes care of this now.
2025-11-15 15:38:24 +01:00
Stefan Haller
7c126cd2fc Strip leading/trailing whitespace from prompt input
This doesn't really solve a pressing problem, because I guess it's unlikely that
users add spaces at the beginning or end of what they type into a prompt; but it
could happen, and in this case we almost always want to strip it. Just adding
this here for completeness while I was working on this code.

The only exception is the input prompt of custom commands, because who knows
what users want to use that input for in their custom command.
2025-11-15 15:38:24 +01:00
Stefan Haller
d7e733cd56 Remove now unnecessary check for empty string
As of the previous commit, branchName can no longer be empty, so no need to
handle this.
2025-11-15 15:38:24 +01:00
Stefan Haller
b3435bd59c Add AllowEmptyInput flag to PromptOpts
Most of our prompts don't (shouldn't) allow empty input, but most callers didn't
check, and would run into cryptic errors when the user pressed enter at an empty
prompt (e.g. when creating a new branch). Now we simply don't allow hitting
enter in this case, and show an error toast instead.

This behavior is opt-out, because there are a few cases where empty input is
supported (e.g. creating a stash).
2025-11-15 15:36:43 +01:00
Stefan Haller
a7bc1012b9 Cleanup: fix incorrect comment
The comment was apparently copy/pasted from above; the branch name cannot be
blank in this case.
2025-11-15 14:46:19 +01:00
Stefan Haller
48330141bd Cleanup: put the IsPasting logic in the right place
Previously it was used both for the Confirm handler and the Cancel handler, as
well as for the Confirm handler of confirmation popups (not prompts). There was
no other way to do it given how wrappedConfirmationFunction was shared between
all these; but now there is. The logic is really only needed for the Confirm
handler of prompts.

This doesn't fix anything, it just makes things clearer.
2025-11-15 14:13:24 +01:00
Stefan Haller
8d8cf42786 Refactor: extract body of wrappedConfirmationFunction into a helper function
And call this new helper function from both wrappedConfirmationFunction and
wrappedPromptConfirmationFunction; this gives us more flexibility to do
different things in each of those.
2025-11-15 14:07:36 +01:00
Stefan Haller
3d5b22f804 Modernize all codes (#5036)
go run
golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest
-fix -test ./...
2025-11-15 10:48:35 +01:00
phanium
d88f95275f Modernize all codes
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...
2025-11-15 10:46:23 +01:00
Stefan Haller
a7126d5456 Allow using SelectedSubmodule in CustomCommands (#5015)
This PR allows the use of `{{ SelectedSubmodule.Path }}`, `{{
SelectedSubmodule.Name }}` and `{{ SelectedSubmodule.Url }}` in custom
commands.
2025-11-12 09:00:22 +01:00
rlkandela
374f0f0766 Add SelectedSubmodule to SessionState
Introduce the 'SelectedSubmodule' struct and allow using it as a
placeholder value.
Add a corresponding test.
Update the documentation to include it among the listed placeholder
values.
2025-11-12 08:54:34 +01:00
rlkandela
7d1c3f7a28 Add submodules context to the docs
The following commits introduce options that may benefit from specifying
the 'submodules' context.
2025-11-12 08:54:33 +01:00
Stefan Haller
dd04cd8f58 Keep config and schema unchanged during a release (#5010)
Some of our documentation is auto-generated from the source code (the
defaults section in Config.md, and the keybinding cheat sheets), and so
is the JSON schema for the config file. We have a check running on CI
that verifies that when the source code changes (e.g. a new config
option is added), those files are properly regenerated, to make sure
they are always up to date with the latest version of the source code.

This causes a problem when people look at the documentation for a newly
added config option and wonder why it doesn't work in the lazygit
version they are using. Lots of issues were filed where people report
this as a bug, and we have to patiently explain to them that the
documentation describes a feature that hasn't been released yet. A
similar problem occurs when we rename a config option (as has recently
happened with the 'paging' config, which was renamed to 'pagers' in
#4953), in which case the user's editor (if it supports JSON validation
against the jsonschema store) starts to complain about the old config,
even though it still works, and the new one doesn't yet.

To solve this, keep the documentation and the JSON schema unchanged for
the lifetime of a release; make those continuous changes in a separate
copy of those folders, and only copy the files back to the real location
right before we make a release. To facilitate this, we add a script to
conveniently create a PR for copying the files back, and add a check to
the release workflow to abort with an error if this was forgotten.

Note that we only use this approach in order to solve the problem with
the auto-generated files; this has a consequence for making changes to
the other, non-auto-generated parts of the docs. For example, when
fixing a spelling error, rewording a paragraph to explain it better, or
adding an entirely new file, those changes will now have to be made in
docs-master, which means:
1. if we forget this and make the change in `docs` accidentally, it will
be reverted with the next release.
2. if we do remember to make the change in docs-master, it will take
until the next release for it to be visible to users.

We can mitigate 2. by making the identical change in both places, but I
think we should first wait and see how often it happens, and whether it
is actually a problem.
2025-11-12 08:47:11 +01:00
Stefan Haller
6ab40df429 Add a check to the release workflow to abort if docs or schema are not up to date
Of course it would be cooler if the workflow could create the PR and merge it if
necessary, but this will have to do for now.
2025-11-12 08:44:56 +01:00
Stefan Haller
7ce1501f3e Add a script for copying the docs and schema over for release
This needs to be run immediately before creating a release.

We could go further here and use gh to create the PR, but since I'm usually
logged in with my work account to gh, this won't help me. The git push command
prints the URL to create the PR, so it's a simple matter of command-clicking it,
which is good enough for me.
2025-11-12 08:44:56 +01:00
Stefan Haller
7627da594d Update generators to change the files in the -master directories 2025-11-12 08:44:56 +01:00
Stefan Haller
d5677318ab Make copies of the docs and schema folders
The plan is to keep the original docs and schema folders unchanged for the
duration of a release; we'll only continuously update the -master copies. Right
before a new release we will copy them over.
2025-11-12 08:44:56 +01:00
Stefan Haller
e3a1fe514c Make link relative
This way it will also work when we make a copy of the entire docs folder.
2025-11-12 08:44:56 +01:00
Stefan Haller
42e4232e56 Keep cursor at top/bottom when navigating by page (#5019)
When pressing '.' (next page) or ',' (previous page), the selection now
stays at the bottom or top of the viewport respectively, instead of
being centered which caused items to scroll off. (If the selection is
not already on the last/first line of the view, '.'/',' moves it there
without scrolling.)

This implements a special case for page navigation as suggested by the
maintainer in issue #5017, keeping the cursor position consistent with
user expectations for page-based navigation.

Fixes #5017
2025-11-09 19:43:48 +01:00
Raphaele Salvatore Licciardo
8114943cb1 Fix page navigation scroll behavior to keep cursor at top/bottom
When pressing '.' (next page) or ',' (previous page), the selection
now stays at the bottom or top of the viewport respectively, instead
of being centered which caused items to scroll off. If the selection is not
already on the last/first line of the view, '.'/',' moves it there without
scrolling.

This implements a special case for page navigation as suggested by
the maintainer in issue #5017, keeping the cursor position consistent
with user expectations for page-based navigation.

Fixes #5017

Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2025-11-09 19:37:38 +01:00
Stefan Haller
2576258ba3 Cleanup: remove unnecessary code
The method is only called from keybinding handlers, so the view must be focused
already, otherwise the binding wouldn't have been dispatched to it.
2025-11-09 19:37:38 +01:00
Stefan Haller
9c0cbd83c7 Open pull requests in browser with extra leading slashes removed (#5018)
### PR Description

This allows for having extra slashes in git URLs. Especially in
submodules. Those may be used to avoid warnings with older bitbake
fetcher implementations in yocto. Which warns about relative urls when
not having a slash in git urls.

- git@bitbucket.org:project/repo.git -> generates a warning in bitbake,
which is annoying.
- git@bitbucket.org:/project/repo.git -> does not generate a warning in
bitbake.

But when trying to open a PR from lazygit with an url like
git@bitbucket.org:/project/repo.git leads to
https://bitbucket.org//project/repo being opened and one has to stare at
a blank page unless one removes the extra / manualy.

This PR updates the regex used for matching git url fragments in a way,
that the extra `/` is ignored.
2025-11-07 16:23:08 +01:00
hrzlgnm
f729e2ca05 Update dead link for debugging regex to regex101.com 2025-11-07 16:00:22 +01:00
hrzlgnm
d5c0d945f8 Open pull requests in browser with extra leading slashes removed
This allows for having extra slashes in git urls, for example to avoid
warnings with older bitbake fetcher implementations in yocto. Which
warns about a missing / in git urls
2025-11-07 16:00:14 +01:00
Stefan Haller
1d17507795 Add a "Commit history" section to CONTRIBUTING.md (#5022)
I see too many PRs with terrible commit histories; maybe this will help
a bit with that.
2025-11-07 13:20:50 +01:00
Stefan Haller
6ff18bbc36 Add a "Commit history" section to CONTRIBUTING.md
I see too many PRs with terrible commit histories; maybe this will help a bit
with that.
2025-11-07 13:12:09 +01:00
Stefan Haller
6aea67ca50 Cleanup: format markdown
I want to be able to press Command-S in VS Code and not have it reformat code
that I didn't edit.
2025-11-07 12:28:15 +01:00
Stefan Haller
aa2bdb0091 README.md: Update Sponsors (#4946)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action
2025-11-02 07:52:00 +01:00
github-actions[bot]
35bba5e556 README.md: Update Sponsors 2025-11-01 08:57:06 +00:00
Stefan Haller
80223c7fbb Fix keybinding cheatsheets with regard to pipe characters in key or description (#5007)
The "Cycle pagers" command wasn't rendered correctly, because it's bound
to '|' by default, but this was taked as a table column delimiter. Fix
this by escaping the pipe character.

A similar thing could happen for the description or tooltip (and did in
fact, for a tooltip in the russion translation), so escape those too
just to be sure.
v0.56.0
2025-11-01 09:56:57 +01:00
Stefan Haller
ff0a16f809 Fix keybinding cheatsheets with regard to pipe characters in key or description
The "Cycle pagers" command wasn't rendered correctly, because it's bound to '|'
by default, but this was taked as a table column delimiter. Fix this by escaping
the pipe character.

A similar thing could happen for the description or tooltip (and did in fact,
for a tooltip in the russion translation), so escape those too just to be sure.
2025-11-01 09:54:32 +01:00
Stefan Haller
48c1db6fe4 Fix fixup's false filename detection in hunks containing dashed lines (#5004)
### PR Description

The existing diff parser incorrectly treated subsequent lines beginning
with `---` as filename headers while processing hunks. This caused
corruption when dashed lines appeared within diffs themselves.

Restrict filename detection to only occur between hunks.

This repository https://github.com/abobov/lazygit-fixup-issue
demonstrates the issue:

- clone repository
- run `git reset --soft HEAD~`
- try `<c-f>` Find base commit for fixup 
- `fatal: no such path ...` error
2025-11-01 09:42:45 +01:00
Anton Bobov
4c4929acad Fix fixup's false filename detection in hunks containing dashed lines
The existing diff parser incorrectly treated subsequent lines beginning
with "---" as filename headers while processing hunks.  This caused
corruption when dashed lines appeared within diffs themselves.

Restrict filename detection to only occur between hunks.
2025-11-01 09:40:04 +01:00
Stefan Haller
f4920e8efa Use a PTY when using external diff command from git config (#4983)
### PR Description

I hit the same issue as
https://github.com/jesseduffield/lazygit/issues/3119 when setting
`useExtDiffGitConfig` to true and using `difftastic` side-by-side
comparison in my git config.

The same fix in https://github.com/jesseduffield/lazygit/pull/3120 needs
to be applied for the newer config option.
2025-11-01 09:35:45 +01:00
Brandon
263ad11b3b Use a PTY when using external diff command from git config
Same logic as https://github.com/jesseduffield/lazygit/pull/3120 but for new external diff option
2025-11-01 09:33:52 +01:00
Stefan Haller
6f0f1e7995 Update translations from Crowdin (#5005) 2025-10-31 19:58:37 +01:00
Stefan Haller
3967edd113 Update translations from Crowdin 2025-10-31 19:56:01 +01:00
Stefan Haller
32a701cb9c Use ignore directive to ignore test files not to be passes to gofumpt (#4936)
### Motivation
To replace the workaround introduced in
https://github.com/jesseduffield/lazygit/pull/4809 with `ignore`
directive to make the code simpler.

### Overview
This is a follow-up PR to
https://github.com/jesseduffield/lazygit/pull/4809.
I have added 4 changes due to updating gofumpt to remove `git ls-files`
workaround.

Please take a look at each commit messages for details.
2025-10-20 07:59:40 +02:00
kyu08
64bcc72e45 Specify return value where named return value is used
After [v0.9.0](https://github.com/mvdan/gofumpt/releases/tag/v0.9.0),
gofumpt prohibits "naked return" for the sake of clarity. This makes
more readable when "named return value" is used.
For more infomation for "prohibition of naked return":
https://github.com/mvdan/gofumpt/issues/285.
2025-10-20 07:56:56 +02:00
kyu08
beb05d4a61 Fix makeAtomic in branches_test
When replacing the naked return with a `return result`, the linter starts to
complain about "return copies lock value: sync/atomic.Int32 contains
sync/atomic.noCopy". I suspect this is also a problem when using a naked return,
and the linter just doesn't catch it in that case. Either way, it's better to
use a pointer to ensure that the atomic is not copied.

Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2025-10-20 07:56:56 +02:00
kyu08
65c27dd8ce Remove workaround for "make format"
When a new enough gofumpt version is used (v0.9.0 or later), it suports the
`ignore` directive that we just added, so the workaround is no longer needed.

Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2025-10-20 07:56:56 +02:00
kyu08
76452a0bcc Add ignore directive in go.mod
This can be used by go tools such as gofumpt.
2025-10-20 07:56:56 +02:00
Stefan Haller
6782f04e8c Add no-ff merge option (#4966)
This will put whatever git's default merge variant is as the first menu
item, and add a second item which is the opposite (no-ff if the default
is ff, and vice versa). Which one is the default depends on whether a
fast-forward merge is possible, and whether users have set git's
`merge.ff` config or lazygit's `git.merging.args` config.

If users prefer to always have the same option first no matter whether
it's applicable, they can make ff always appear first by setting git's
`merge.ff` config to "true" or "only", or by setting lazygit's
`git.merging.args` config to "--ff" or "--ff-only"; if they want no-ff
to appear first, they can do that by setting git's `merge.ff` config to
"false", or by setting lazygit's `git.merging.args` config to "--no-ff".
Which of these they choose depends on whether they want the config to
also apply to other git clients including the cli, or only to lazygit.

Closes #4091.
2025-10-19 21:26:31 +02:00
Stefan Haller
62854026a3 Add no-ff merge option
This will put whatever git's default merge variant is as the first menu item,
and add a second item which is the opposite (no-ff if the default is ff, and
vice versa).

If users prefer to always have the same option first no matter whether it's
applicable, they can make ff always appear first by setting git's "merge.ff"
config to "true" or "only", or by setting lazygit's "git.merging.args" config to
"--ff" or "--ff-only"; if they want no-ff to appear first, they can do that by
setting git's "merge.ff" config to "false", or by setting lazygit's
"git.merging.args" config to "--no-ff". Which of these they choose depends on
whether they want the config to also apply to other git clients including the
cli, or only to lazygit.
2025-10-19 21:24:28 +02:00