1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2026-04-07 19:17:06 +02:00
Commit Graph

4661 Commits

Author SHA1 Message Date
Stefan Haller
f47ee726c7 Update translations from Crowdin 2026-04-06 19:29:09 +02:00
Martin T.
4cb6fafb08 Add condition field to custom command prompts
When building multi-step custom command forms, some prompts are only
relevant depending on earlier answers. Without conditional logic,
users must dismiss irrelevant prompts manually.

Prompts now accept a `condition` field with a template expression
evaluated against prior form values. Skipped prompts default to
an empty string.

The template expression is a string pre- and suffixed with double curly
braces - {{}}.

Form keys can be reused, a guard ensures that skipped prompts do not
reset already set form keys with an empty string. This allows the
conditional flow to remind a user to set a key that was left empty
because additional conditions want that key to be set. This removes the
need to have additional if checks in the command that uses the form
keys.
2026-04-06 19:14:51 +02:00
Stefan Haller
e4309f101c Log hashes of local branches when deleting them
This makes it easier to recover them if they were deleted accidentally.

We only do this for local branches for now, we don't bother for remote branches;
it would be trickier there, because the branch on the server might not actually
point to the same hash as our local remote tracking branch does.
2026-04-06 19:06:25 +02:00
Stefan Haller
710a73e351 Add missing quote 2026-04-06 19:06:25 +02:00
Stefan Haller
7918858023 Localize "Dropping stash" log
This was forgotten in #4850.
2026-04-06 19:06:25 +02:00
Stefan Haller
e92b04e1dc Don't refresh pull requests when checking out a local branch
For esthetic reasons, checking out a branch (or other ref) blocks the UI until
the refresh is done, so it's important that the refresh doesn't do unnecessary
work. Refreshing pull requests is unnecessary (but costly, when waiting for it)
when a branch is checked out that already existed locally. However, it is
required when checking out a remote branch for the first time, so that the PR
icon appears immediately when there is one.
2026-04-01 09:13:55 +02:00
Stefan Haller
6ba46ad604 Change "Copy pull request URL to clipboard" command to use existing PR if there is one 2026-04-01 09:13:55 +02:00
Stefan Haller
a462b7c420 Add commands for opening a Github PR in the browser
For the branches panel we might consider unifying it with the existing `o`
command for creating a PR: it could check if there is a PR already, and open it
if so, or create a new one if not.

However, I also want the command in the local commits panel for the checked out
branch, and there's no existing "Create PR" command there; and the `o` command
opens the selected commit in the browser, so it's unrelated.
2026-04-01 09:13:55 +02:00
Stefan Haller
6145eaf939 Prompt only once per session for each repo
If the user hits escape in the "Select base repository for pull requests"
prompt, don't bother them again for this repo at the next refresh.
2026-04-01 09:13:55 +02:00
Stefan Haller
28affa3399 Add an optional onCancel hook for menus 2026-04-01 09:13:55 +02:00
Stefan Haller
7a0320b4ec Call OnMenuPress(nil) when hitting esc in a menu
OnMenuPress can already deal with the selected item being nil, so this allows us
to add common code to it that is run when cancelling the menu.
2026-04-01 09:13:55 +02:00
Stefan Haller
2ab78ad039 Show PR information in main view, above the branch log 2026-04-01 09:13:55 +02:00
Jesse Duffield
fff6003044 Cache PRs in AppState so that they appear immediately at startup
Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2026-04-01 09:13:55 +02:00
Jesse Duffield
ca9eeebea3 Show PR icons in branches list
Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2026-04-01 09:13:55 +02:00
Jesse Duffield
d33fa5bb05 Add pull requests to lazygit's model and refresh them
Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2026-04-01 09:13:55 +02:00
Jesse Duffield
1c89398288 Add GitHub commands and model for fetching PR status
Add GitHubCommands struct with GraphQL-based PR fetching, and
GithubPullRequest model. Wire HostingService and GitHub command
structs into GitCommand.

Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2026-04-01 09:13:55 +02:00
Jesse Duffield
4cd72b09a2 Refactor hosting service to support repo name extraction
Extract parseRemoteUrl helper to avoid duplication between
getRepoURLFromRemoteURL and new getRepoNameFromRemoteURL.
Add repoNameTemplate to ServiceDefinition and GetRepoName() to
HostingServiceMgr. Add GetRepoInfoFromURL for callers that need
owner/repo without a full service lookup.
2026-03-31 15:48:28 +02:00
Stefan Haller
649679c33a Remove branch icons from Branches list
The only information that this carries is whether an entry is a real branch or a
detached head. Detached heads can only be at the top, and they are easy to tell
apart from the other branches by their name, so the icon is not really very
useful.

We are going to show PR icons in this column.
2026-03-31 15:48:28 +02:00
Stefan Haller
968c44b02f Add missing entries to scopeNameMap 2026-03-31 15:48:28 +02:00
Stefan Haller
47db2c24cf Allow turning off nerd fonts without restarting
Not a terribly important feature for users, probably, but it is useful for
developers when testing a new feature with or without nerd fonts; and it does go
against or policy of all configs being hot-reloadable.

Note that switching from nerd fonts version 2 to 3 is *not* supported without
restarting, but I find this less important.
2026-03-31 15:48:28 +02:00
Stefan Haller
fde4bc1fb2 Allow customizing the window width/height thresholds for when to use portrait mode 2026-03-31 13:08:46 +02:00
Stefan Haller
f8fd8d04bc Fix typo 2026-03-31 13:08:46 +02:00
phanium
41cd78af48 Fix panic when branch.autosetuprebase is set
It actually expect `branch.<name>.*`

`man git-config | rg "\s+branch\.\S+\$"` to show all possible keys.
2026-03-31 09:58:57 +08:00
Stefan Haller
b8d23dd5a5 Make file sort order and case sensitivity configurable
Set the sort order's default from the former foldersFirst to mixed, so this is a
change in behavior. I find this useful because it now matches git's order, so if
you look at the diff of a commit, the TOC at the top has the same order as the
file tree you see when entering the commit.
2026-03-30 17:53:25 +02:00
Stefan Haller
2a6648f0f6 Remove empty directories after discarding files
When discarding untracked files, remove any directories that have become empty
because of this.
2026-03-30 17:50:28 +02:00
Stefan Haller
b4dae453af Extract helper method removeFiles 2026-03-30 17:50:28 +02:00
Stefan Haller
46d8437bc2 Change test setup to allow nested directories 2026-03-30 17:50:28 +02:00
Stefan Haller
9f38d02a4e Don't stage out-of-date submodules when asking user to auto-stage after resolving conflicts
When you rebase a branch and there are conflicts, lazygit asks you to continue
the rebase when it detects that all conflicts have been resolved. However, it is
common to make additional changes beyond just fixing the conflicts (e.g. to fix
build failures), and when doing that while the "Continue the rebase?" prompt is
showing, lazygit detects that too and asks you if you want to stage those newly
modified files too. This is all well and good (and can be disabled for those who
don't like it); however, lazygit would treat out-of-date submodules as unstaged
changes and would offer to stage those as well, and this is pretty bad and
almost never what you want. Fix this by excluding submodules from that second
check.
2026-03-30 17:41:53 +02:00
Stefan Haller
58bcfc4347 Add test to demonstrate the problem 2026-03-30 17:34:18 +02:00
Matthijs Kooijman
590d6f2f80 Fix patch commands when git config has color=always
This is the same option as used by pkg.commands.git_commands.diff.GetDiff().
2026-03-30 10:42:26 +02:00
Stefan Haller
781105c49b Scroll to top when showing subcommits
Previously, when showing subcommits of a branch or tag, scrolling down, and then
going out and entering subcommits again, it would select the first commit but
keep the previous scroll position, so that the selection was not visible. Always
scroll to the top to fix this.
2026-03-27 14:55:02 +01:00
Stefan Haller
4d46f5af94 Improve performance for discarding range selection of many files
This is probably the less severe case, but it could still be an issue for people
who have many modified top-level files they want to discard, and have
showRootItemInFileTree set to false; they could select all those files by
pressing 'v' and '>'.
2026-03-27 14:34:47 +01:00
Stefan Haller
ad31400818 Improve performance of discarding changes in large directories
Previously it would iterate over all changed files and call git checkout or git
reset for each one, which can take forever if there are hundreds or thousands of
files. Now it batches these into a single command if possible (taking care of
still passing the individual path names to the git call rather than just the
directory, which is necessary for making it work correctly when filtering --
this was actually broken for the "Discard unstaged changes" command, which is
fixed here).
2026-03-27 14:34:47 +01:00
Stefan Haller
e434f5b5e9 Add runGitCmdOnPaths utility
Useful when we need to call git with potentially tons of arguments that might
exceed the OS' command-line length limit.
2026-03-27 14:34:47 +01:00
Stefan Haller
f987b35a9e Add integration tests for discarding dir changes when filtering by path
When discarding a directory, we only want to discard those files that are
visible in the current filter view. The tests show that this already works
correctly for discarding all changes, but it doesn't for discarding only
unstaged changes: in this case, untracked files are handled correctly, but
changes to tracked files are discarded without respecting the filter.
2026-03-27 14:34:47 +01:00
Stefan Haller
5b829a6721 Add unit tests for WorkingTreeDiscard{All,Unstaged}DirChanges
We have integration tests for this functionality, but those only test the
behavior, not the performance. In these unit tests you can see that we make
individual calls to git checkout and git reset for each file, which is very slow
when there are lots of files.
2026-03-27 14:34:47 +01:00
Stefan Haller
4aa455e4eb Cleanup: better check for which files are removed
Previously it would only check that *if* removeFile was called, the passed
argument was the expected one; but it didn't check whether it was called at all.
Improve this by recording the file names that are removed, and checking them at
the end of each scenario.

This is going to be even more important for the tests that we are about to add
in the next commit, because for those there can be several calls to removeFile
in a single scenario.
2026-03-27 14:34:47 +01:00
Stefan Haller
4a8ab6f64e Cleanup: simplify by using lo.FilterMap instead of separate calls to Filter and Map 2026-03-27 14:34:47 +01:00
Stefan Haller
706a6c0474 Cleanup: use oscommands.RemoveFile rather than plain os.Remove
This makes it mockable for tests, and is consistent with other uses in this
file.
2026-03-27 14:34:47 +01:00
Stefan Haller
3eb5841b83 Fix searching commits or main view after switching repos
When switching to a different repo, and then back to the original one, searching
would no longer work. The reason is that our contexts set callbacks on their
views; when switching to a different repo we instantiate a new set of contexts,
so they will overwrite the views' callbacks with their new ones, but when
switching back to the original repo, we reuse the old contexts because they are
still in memory, but they won't set their callbacks again since they only do
this on construction.

To fix this, replace the view-local callbacks with a global one on the gui that
takes the view as an argument, so that the callback can look up the associated
context dynamically.
2026-03-27 14:26:20 +01:00
Stefan Haller
a930f74397 Remove go-git repo from GitCommon
It is no longer used now.
2026-03-27 14:08:07 +01:00
Stefan Haller
6f9d234116 Remove go-git repo from ConfigCommands 2026-03-27 14:08:07 +01:00
Stefan Haller
1da87b9a7c Don't use go-git to parse branches
As with the previous commit, the code to parse `git config --get-regex` output
on our end isn't so bad.
2026-03-27 14:04:51 +01:00
Stefan Haller
23f973496f Don't use go-git to parse remotes
It only takes a few lines of code to parse remotes on our end from the output of
`git config --get-regexp`.
2026-03-27 14:00:58 +01:00
blakemckeany
ee3bb06b2a Add support for clicking on arrows in the file list to expand/collapse directories
Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2026-03-25 17:08:35 +01:00
blakemckeany
4567840198 Add GetOnClick to HasKeybindings
Can be used for doing additional click handling in list views.

Like the GetOnDoubleClick hook we should try to find a better design for this
than putting it in HasKeybindings and BaseContext, since it is only used by list
contexts.

Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2026-03-25 17:08:02 +01:00
blakemckeany
61b72cef38 Add GetVisualDepth method to FileTree/CommitFileTree 2026-03-25 16:41:12 +01:00
Stefan Haller
fe5df2334b Document some of the methods of HasKeybindings
We have some documentation for the corresponding setters in IBaseContext, but
that's part of the controller infrastructure and not client facing. For somebody
implementing a new view, this is where they will probably look for what methods
they can override.
2026-03-25 16:41:10 +01:00
Stefan Haller
72bff90822 Rename GetOnClick (et al) to GetOnDoubleClick
When this was originally introduced, it handled single clicks on a list entry
(treating them similar to a double-click by checking whether the click was on
the selected entry). Arguably it should have been called OnDoubleClick back then
already; but when we later changed it to do actual double-click detection (see
37197b8e9a), we should have renamed the methods.
2026-03-25 14:58:53 +01:00
Stefan Haller
d9487bf31c Fix the expanded layout of the branches panel (half and full screen modes)
If the showDivergenceFromBaseBranch config is not none, the expanded branches
panel would no longer show the remote branch and subject; the reason was that we
padded the name all the way to the right edge of the view so that the divergence
information is right-aligned.

To fix this, we simply don't right-align the divergence in half or full screen
mode. This is a bit unfortunate, but it's hard to do any better, because we
don't know the width of our column in advance. One thing I tried is to make the
divergence a separate column in that case (with an explicit right-alignment set
on it via getColumnAlignments; however, this makes it harder to properly
truncate the name when the window is too narrow.
2026-03-23 17:25:41 +01:00