1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-25 12:24:47 +02:00

5231 Commits

Author SHA1 Message Date
Stefan Haller
3b29705a78 Add config to truncate commit hashes when copying them to the clipboard
I often copy hashes in the commits panel in order to paste them into Github
comments (or other places), and I can't stand it when they have the full length.

I picked a default of 12 for this; I find this to be a good middle ground
between being reliable in large repos (12 still works in the linux kernel repo
today, but it might not be enough in really huge repos) and not being too ugly
(many smaller repos can probably get away with less).

We deliberately don't change this for the "Copy to clipboard" menu, since this
gives users a way to copy the unabbreviated sha if they need this occasionally.
2024-03-22 09:58:54 +01:00
Stefan Haller
28dd7f9467
Make it easy to create "amend!" commits (#3409)
- **PR Description**

To support this, we turn the confirmation prompt of the "Create fixup
commit" command into a menu; creating a fixup commit is the first entry,
so that "shift-F, enter" behaves the same as before. But there are
additional entries for creating "amend!" commits, either with or without
file changes. These make it easy to reword commit messages of existing
commits.
2024-03-22 08:32:16 +01:00
Stefan Haller
150cc70698 Make it easy to create "amend!" commits
To support this, we turn the confirmation prompt of the "Create fixup commit"
command into a menu; creating a fixup commit is the first entry, so that
"shift-F, enter" behaves the same as before. But there are additional entries
for creating "amend!" commits, either with or without file changes. These make
it easy to reword commit messages of existing commits.
2024-03-22 08:27:45 +01:00
Stefan Haller
c92e9d9bdc Remove CreateFixupCommitDescription as it's identical to CreateFixupCommit 2024-03-22 08:27:45 +01:00
Stefan Haller
e23337f8f5
Support editing multiple files at once using range selection (#3407)
- **PR Description**

This makes it possible to select a range of files (either in the files
panel, or in the commit-files panel), and hit `e` to open them all at
once in the editor.

We pass all of them to a single editor command, hoping that the editor
will be able to handle multiple files (VS Code and vim do).

We ignore directories that happen to be in the selection range; this
makes it easier to edit multiple files in different folders in tree
view. We show an error if only directories are selected, though.
2024-03-22 08:22:46 +01:00
Stefan Haller
73019574a8 Support editing multiple files at once using range selection
We pass all of them to a single editor command, hoping that the editor will be
able to handle multiple files (VS Code and vim do).

We ignore directories that happen to be in the selection range; this makes it
easier to edit multiple files in different folders in tree view. We show an
error if only directories are selected, though.
2024-03-22 08:20:16 +01:00
Stefan Haller
9b5269b490
When adding a new remote, select it and fetch it (#3401)
- **PR Description**

I'm doing these two things every time I add a new remote, in 100% of the
cases, so do them automatically for me.
2024-03-22 08:19:45 +01:00
Stefan Haller
e8db27b0b3 When creating a new remote, select it and fetch it
I'm doing these two things every time I add a new remote, in 100% of the cases,
so do them automatically for me.
2024-03-22 08:17:12 +01:00
Stefan Haller
337a0dbc9b
Make the links in the status panel point to the current version rather than master (#3397)
We've seen a lot of issues recently where people complain that lazygit
doesn't behave as documented, but that was only because they were
running the latest release but were looking at the documentation of
master. Make the documentation links in the status panel point to the
release that they are using in the hope that this will help a little bit
with this problem.
2024-03-22 08:16:20 +01:00
Stefan Haller
5870133924 Make links in status view clickable, and underline them 2024-03-22 08:13:59 +01:00
Stefan Haller
fa79c92748 Make the links in the status panel point to the current version rather than master
We've seen a lot of issues recently where people complain that lazygit doesn't
behave as documented, but that was only because they were running the latest
release but were looking at the documentation of master. Make the documentation
links in the status panel point to the release that they are using in the hope
that this will help a little bit with this problem.
2024-03-22 08:13:59 +01:00
Stefan Haller
251bfb6a24
Always prompt to return from subprocess if there was an error (#3410)
- **PR Description**

When lazygit suspends itself to the background to run an external
command, and the command returns a non-zero exit code, always show the
prompt for pressing enter to return to lazygit, even if the
`promptToReturnFromSubprocess` is set to `false`. The rationale is that
if the process returned an error, it likely also printed some error
message to the console that users will always want to read.

I was considering turning the `promptToReturnFromSubprocess` config into
an enum with values `never`, `onlyOnError`, `always`, but then I felt
that `onlyOnError` is really the only sensible choice for people who
have it set to `false` now, so I just hard-coded that.
2024-03-22 08:13:15 +01:00
stk
377eced31a Always prompt to return from subprocess if there was an error
Except when we are running integration tests, in which case we never want to
prompt because there wouldn't be a way to confirm the prompt.
2024-03-21 14:17:10 +01:00
Stefan Haller
fadc2893d2
Add NixOs installation instructions to README.md (#3249)
Extend README.md with instructions on how to try and install the lazygit
on NixOs.
2024-03-19 12:38:20 +01:00
Radosław Śnieżek
1e59de2768 Add NixOs installation instructions README.md
Extend README.md with instructions on how to try and install
the lazygit on NixOs.
2024-03-19 12:32:13 +01:00
Stefan Haller
1d4448d691
Fixed translations for zh_TW (#3393)
- **PR Description**

Improve translations for Traditional Chinese.
2024-03-19 07:59:59 +01:00
Stefan Haller
2c33f0ce1f Fix indentation 2024-03-19 07:55:23 +01:00
Stefan Haller
14b3e0574c Improve translations for zh_TW
Authored-by: Oliver Tzeng <olivertzeng@proton.me>
2024-03-19 07:55:23 +01:00
Stefan Haller
318a399bfb
Fix enabling/disabling of ctrl-o in commit message panel (#3395)
- **PR Description**

This fixes two minor regressions introduced in #3097 related to commands
that open a commit message panel but don't set an onSwitchToEditor
function (an example is the commit message panel that appears when
moving a custom patch to a new commit):
- the "Press <c-o> to open menu" hint was hidden. That's wrong, it is
still possible to open the menu in this case. (And it still worked, we
just wouldn't show the hint.)
- invoking the "open in editor" menu item would silently do nothing. Now
we set a DisabledReason for the item in this case.
2024-03-19 07:13:20 +01:00
Stefan Haller
7764e6d1cb Fix disabling the switch-to-editor menu item if unavailable
Some operations don't support switching to the editor from the commit message
panel; an example is the commit message panel that appears when moving a custom
patch into a new commit. Disable the "open in editor" menu entry in this case,
instead of silently doing nothing.
2024-03-18 21:10:58 +01:00
Stefan Haller
1a9ce9db94 Always show the "Press <c-o> to open menu" help text in the commit panel
Previously we would hide it if no onSwitchToEditor function was set; that was
from a time when <c-o> was bound directly to the switch-to-editor command. Now
it is bound to showing a menu, and that menu is always available even if no
onSwitchToEditor function is set. (We rather need to disable the switch to
editor item _within_ that menu, see next commit.)
2024-03-18 20:44:03 +01:00
Stefan Haller
9a3db0dfbd
Update translations for polish language (#3389)
- **PR Description**

Hi, I'm happy using `lazygit` from quite a while. I've decided to give
back to community fraction of my time. I'm native polish speaker, and
seen that polish translation have some gaps.

I've added missing translation for polish language and improved existing
one. I've followed technical jargon used on
https://git-scm.com/book/pl/v2/
 
For easier diff comparison and feature maintenance, I've ordered keys to
be in same order as those in `english.go`
2024-03-17 18:53:13 +01:00
undg
d65b21d6b8 Add missing translations for polish 2024-03-17 18:46:19 +01:00
Stefan Haller
435a835c51
Use substring filtering instead of fuzzy filtering by default (#3376)
By default we now search for substrings; you can search for multiple
substrings by separating them with spaces. Add a config option
`gui.filterMode` that can be set to 'fuzzy' to switch back to the
previous behavior.

Addresses #3373.
2024-03-17 12:28:13 +01:00
Stefan Haller
4f2bebe453 Get rid of the retain-sort-order-when-filtering logic again
For die-hard fuzzy-searching fans it's probably in the way, so taking it out
makes fuzzy filtering work better. For substring filtering it always retains the
sort order anyway.
2024-03-17 12:23:07 +01:00
Stefan Haller
7d2163d632 Rename FuzzySearchFunc to FilterFunc
It isn't necessarily fuzzy any more.
2024-03-17 11:56:29 +01:00
Stefan Haller
561afa9901 Rename FuzzySearch to FilterStrings
It isn't necessarily fuzzy any more.
2024-03-17 11:55:30 +01:00
Stefan Haller
a8797c7261 Default to substring filtering, add option to go back to fuzzy filtering
By default we now search for substrings; you can search for multiple substrings
by separating them with spaces. Add a config option gui.filterMode that can be
set to 'fuzzy' to switch back to the previous behavior.
2024-03-17 11:55:09 +01:00
Stefan Haller
a82e26d11e Don't sort the results of fuzzy.Find
It sorts them already, so it's unnecessary. In the next commit we use this same
code for substring searching too, and in that case we don't want to sort because
sorting is by Score, but we don't even fill in the score for substring
searching.
2024-03-17 07:57:19 +01:00
Stefan Haller
2cf8e7bc5c
When checking out a remote branch by name, ask the user how (#3388)
- **PR Description**

When checking out a remote branch by name, ask the user how they want to
check it out; the choices are to create a new local branch that tracks
the remote, or a detached head.

This is an alternative to #3371, and fixes #2312.
2024-03-17 07:56:12 +01:00
Stefan Haller
6932e04708 Refresh after creating local branch, before checking it out
This way we see the local branch immediately when switching to the branches
view, and we see an inline waiting status on it when checking it out.
2024-03-17 07:53:38 +01:00
Stefan Haller
30db7234d9 Show inline waiting status when checking out a local branch 2024-03-17 07:53:38 +01:00
Stefan Haller
0d5c748fe8 Show the same menu when pressing space on a remote branch
The old behavior of showing a prompt to choose a name for the new local branch
is still available via the 'n' keybinding.
2024-03-17 07:53:38 +01:00
Stefan Haller
e42cbf95ae When checking out a remote branch by name, ask the user how
The choices are to create a new local branch that tracks the remote, or a
detached head.
2024-03-17 07:53:38 +01:00
Stefan Haller
0360b82aab
Don't ask to force-push if the remote rejected updates (#3387)
Lazygit has two ways to decide whether it needs to ask the user to
force-push:
1. if it knows ahead of time that the push will fail because the branch
has diverged, by looking at the incoming/outgoing information that it
shows as ↑3↓7.
2. by examining the error that comes back when the push has failed.

The second situation should happen only rarely, because lazygit fetches
every minute by default, so the ↑3↓7 information is usually up to date.
It might not be if the user turned off auto-fetch (or increased the
auto-fetch interval). However, in this case it's almost always harmful
to prompt the user to force-push, because we know that the reason for
diverging is that something was pushed to the remote, and we would wipe
it out by force-pushing. In such a situation, the more likely user
action is to pull the remote changes and then push normally again.

So just remove the second prompt, and replace it by a better error
message when we detect that updates were rejected remotely.

A little bit of history archeology reveals that the second prompt was
added at a time where we didn't have the first one yet, so at that time
it made sense to have it; but when the first prompt was added, we should
have removed the second.
2024-03-17 07:42:34 +01:00
Stefan Haller
81b497d186 Don't ask to force-push if the remote rejected updates
Lazygit has two ways to decide whether it needs to ask the user to force-push:
1. if it knows ahead of time that the push will fail because the branch has
diverged, by looking at the incoming/outgoing information that it shows as ↑3↓7.
2. by examining the error that comes back when the push has failed.

The second situation should happen only rarely, because lazygit fetches every
minute by default, so the ↑3↓7 information is usually up to date. It might not
be if the user turned off auto-fetch (or increased the auto-fetch interval).
However, in this case it's almost always harmful to prompt the user to
force-push, because we know that the reason for diverging is that something was
pushed to the remote, and we would wipe it out by force-pushing. In such a
situation, the more likely user action is to pull the remote changes and then
push normally again.

So just remove the second prompt, and replace it by a better error message when
we detect that updates were rejected remotely.

A little bit of history archeology reveals that the second prompt was added at a
time where we didn't have the first one yet, so at that time it made sense to
have it; but when the first prompt was added, we should have removed the second.
2024-03-17 07:38:58 +01:00
Stefan Haller
e9d050c5d5
Allow moving and deleting update-ref todos (#3391)
- **PR Description**

Previously it wasn't possible to move an update-ref entry up or down
using ctrl-j and ctrl-k, or to delete an update-ref entry. For moving, a
work-around was to move the surrounding commits instead, but it's still
nice to be able to do it directly. Deleting is very much necessary
though, since there are situations where git adds the update-ref entries
but they are not wanted; one example is if you want to make a copy of a
branch and rebase to a different place, without the original branch
following it. (There's a long discussion about this
[here](https://public-inbox.org/git/adb7f680-5bfa-6fa5-6d8a-61323fee7f53@haller-berlin.de/).)

Update-ref todos can't be set to "drop" like other todos, because they
have no sha associated with them, so we need to delete them immediately.
We show a confirmation before doing that, because you'd have to abort
the rebase if you do it accidentally.

We allow range selecting normal todos and update-ref todos at the same
time; in that case, we delete all the update-ref todos and set all the
other ones to "drop". Not that this is an absolutely necessary feature,
but it wasn't hard to do.
2024-03-17 07:38:25 +01:00
Stefan Haller
5c56bc7015 Set mode to none when calling SetSelectionRangeAndMode with empty non-sticky range
So far, the only situation where we called SetSelectionRangeAndMode was one
where the range could only get larger (in startInteractiveRebaseWithEdit, in
which case update-ref todos can be inserted by the rebase). However, in the last
commit we introduced a new call site where the range can get smaller, including
being reduced to a single item. Since this is indistinguishable from a single
selection, set the mode to none in this case; without this, hitting escape would
seemingly do nothing because it collapses the empty range selection.
2024-03-16 22:01:13 +01:00
Stefan Haller
0608fc6471 Allow deleting update-ref todos 2024-03-16 22:01:13 +01:00
Stefan Haller
64a1a455d6 Extract a findTodo helper function
We will reuse it in the next commit.
2024-03-16 22:01:03 +01:00
Stefan Haller
bd975a8dcb Allow moving update-ref todos up/down 2024-03-16 22:01:03 +01:00
Stefan Haller
e5fa9e1c4a Store full ref in Name field of update-ref commits
Strip the prefix at presentation time instead. This makes it easier to find
update-ref todos in order to move them up/down, or delete them.
2024-03-16 15:48:34 +01:00
Stefan Haller
e8d84a1f2c Refactor: pass Todo to moveTodoUp/Down instead of Sha and Action
We need this because we want to enable moving update-ref todos, which don't have
a sha.
2024-03-16 15:21:17 +01:00
Stefan Haller
fd18db6ba2
Show "breaking changes" message at startup (#3377)
- **PR Description**

Remember which version of lazygit the user was last running, and show a
list of breaking changes since that version (if any) if the user
upgraded to a newer version.

It's a little unobvious how to test this manually, because we don't show
the popup for developer builds. You'll have to build with something like
`go build -ldflags="-X 'main.version=0.41.0'"` in order to test it.

This is an extremely stripped down version of #3261.
2024-03-12 13:30:19 +01:00
Stefan Haller
36fa25fa6d Handle mouse-wheel scrolling in confirmation panel
This can easily happen for the breaking changes panel when there are many.
2024-03-12 13:27:14 +01:00
Stefan Haller
2f4437591e Show popup message with breaking changes on startup 2024-03-12 13:27:14 +01:00
Stefan Haller
d12ceeb1ec
Add Co-Author support to new commits (#3097)
- Adds Co-Author support to commit menu (`<C-o>` by default) 
  - `e` Opens up the commit message in your editor
  - `c` Lets you add a co author to your commit
- Cleans up and amend commit attribute menu related code
2024-03-12 08:40:47 +01:00
Stefan Haller
1ec87364fe Add integration test 2024-03-11 09:19:11 +01:00
Abhishek Keshri
7c687938a5 Add commit menu entry "Add co-author" 2024-03-11 09:18:55 +01:00
Abhishek Keshri
744519de60 Add a commit menu to the commit message panel
And move the "switch to editor" command into this menu. So far this is the only
entry, but we'll add another one in the next commit.
2024-03-11 09:18:40 +01:00