Commit Graph
100 Commits
Author SHA1 Message Date
Stefan Haller 150260c8a1 Update keybinding names to match names in menu 2024-02-02 18:42:24 +01:00
Stefan HallerandGitHub 49df908dd3 Fix cherrypick demo (#3287)
Cherrypick selections are now cleared after pasting (#3240), so the demo
needs a tiny change to reflect that.

- **PR Description**
The cherry pick demo is failing after the changes in #3240. This is just
a small update to that demo to reflect the new (and more convenient)
behavior from #3240.

- **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))
* [ ] Docs (specifically `docs/Config.md`) 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
-->
2024-01-30 17:10:10 +01:00
Stefan HallerandGitHub 607034a61e Clear cherry-picked commits after pasting (#3240)
It can be tedious after each cherry-pick opearation to clear the
selection by pressing escape in order for lazygit to stop displaying
info about copied commits. Also, it seems to be a rare case to
cherry-pick commits to more than one destination.

The simplest solution to address this issue is to clear the selection
upon paste, including merge conflict scenario.
Previously discussed in #3198.
2024-01-30 08:59:38 +01:00
Stefan HallerandGitHub 9d840088ac Add command to squash all fixups in the current branch (#3274)
Add command to squash all fixups in the current branch.

To do that, change the "Apply fixup commits" command to show a menu with
the two choices "in current branch" and "above the selected commit"; we
make "in current branch" the default, as it's the more useful one most
of the time, even though it is a breaking change for those who are used
to "shift-S enter" meaning "squash above selected".

Fixes #3263.
2024-01-29 10:05:40 +01:00
Stefan Haller b133318b40 Add command to squash all fixups in the current branch
To do that, change the "Apply fixup commits" command to show a menu with the two
choices "in current branch" and "above the selected commit"; we make "in current
branch" the default, as it's the more useful one most of the time, even though
it is a breaking change for those who are used to "shift-S enter" meaning
"squash above selected".
2024-01-29 09:37:47 +01:00
Stefan HallerandGitHub 24e79a057c Fix refreshing custom patch view when adding first file to custom patch (#3266)
Fixes #3258.
2024-01-28 10:01:49 +01:00
Stefan Haller c66667c8c1 Fix main view refresh after adding the first file to a custom patch
This broke with 240948b.
2024-01-28 09:49:56 +01:00
Stefan Haller e8e7ddea45 Fix typo 2024-01-28 09:49:56 +01:00
Stefan HallerandGitHub cb1b13e95e Keep same selection range when quick-starting an interactive rebase (#3247)
This is useful if you want to move a range of commits, so you select
them, and then realize it's better to do it in an interactive rebase. Pressing 'i'
preserves the range now.
2024-01-26 11:26:00 +01:00
Stefan Haller f9876c9742 Keep same selection range when quick-starting an interactive rebase
This is useful if you want to move a range of commits, so you select them, and
then realize it's better to do it in an interactive rebase. Pressing 'i'
preserves the range now.
2024-01-26 11:18:13 +01:00
Stefan Haller d28a2ec059 Add tests for preserving the selection when pressing 'i'
Preserving the selection for a non-range selection already works as expected;
however, the test for a selection range shows an undesired behavior.
2024-01-26 11:18:06 +01:00
Stefan Haller f226a277bf Rename MinMax to SortRange 2024-01-26 11:18:06 +01:00
Stefan HallerandGitHub a65f003ccc Inline status for fetching remotes (#3238)
When fetching a remote in the remotes tab, show the status inline (i.e.
in the list row of the remote), like we do when fast-forwarding a branch
in the branches panel.
2024-01-26 08:48:05 +01:00
Stefan Haller b485363006 Remove unused text FetchingRemoteStatus
We just removed the last use of it.
2024-01-26 08:29:04 +01:00
Stefan Haller 7fb5266027 Use inline status for fetching remotes 2024-01-26 08:29:04 +01:00
Stefan HallerandGitHub ae89dde969 Pass absolute file paths to all editor commands (#3255)
- **PR Description**

This helps work around bugs in editors that may get confused about
relative paths (like nvim-remote, see
https://github.com/neovim/neovim/issues/18519), and shouldn't have any
negative effect on others.
2024-01-26 08:26:54 +01:00
Stefan Haller 12500be554 Pass absolute file paths to all editor commands
This helps work around bugs in editors that may get confused about relative
paths (like nvim-remote, see https://github.com/neovim/neovim/issues/18519), and
shouldn't have any negative effect on others.
2024-01-25 08:56:10 +01:00
Stefan HallerandGitHub b7d4db2446 Use git rev-parse to obtain repository and worktree paths (#3183)
- **PR Description**
This changes GetRepoPaths() to pull information from `git rev-parse`
instead of partially reimplementing git's logic for pathfinding. This
change fixes issues with bare repos, esp. versioned homedir use cases,
by aligning lazygit's path handling to what git itself does. I believe
it also paves the way for lazygit to run from any subdirectory of a
working tree with relatively minor changes.

Addresses #1294 and #3175.

- **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] Docs (specifically `docs/Config.md`) 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
-->
2024-01-24 08:47:49 +01:00
Stefan HallerandGitHub 74d937881e Make range selections created with the mouse non-sticky (#3234)
- **PR Description**

I prefer this because I almost never use sticky range selections, but
I'm not sure everybody agrees. Also, this fixes the issue that just
clicking a line in a diff (without dragging) already creates a range
selection. It still does, technically, but it's no longer a problem
because a non-sticky one-line range selection behaves the same as a
non-range selection.

See #3233.
2024-01-24 08:26:33 +01:00
Stefan Haller e72c759541 Make range selections created with the mouse non-sticky
I prefer this because I almost never use sticky range selections. Also, this
fixes the issue that just clicking a line in a diff (without dragging) already
creates a range selection. It still does, technically, but it's no longer a
problem because a non-sticky one-line range selection behaves the same as a
non-range selection.
2024-01-24 08:22:55 +01:00
Stefan HallerandGitHub a67ad44781 Add config setting to suppress showing file icons (#3216)
- **PR Description**

Add a config option `gui.showFileIcons` (default: true) which can be set
to false to suppress showing file icons.
2024-01-22 08:43:54 +01:00
Stefan Haller 36134006c5 Add config setting to suppress showing file icons 2024-01-22 08:40:03 +01:00
Stefan HallerandGitHub 221ebdc1fb Keep same branch selected when fetching a branch while sorted by date (#3186)
- **PR Description**

Now that branches can be sorted by date, there's a new situation that we
didn't have before: when fetching a branch, its committer date can
change, so it will move up in the list; we need to update the selection
index to follow. This is important for the case that master is behind
its upstream and you want to rebase your checked-out branch onto master:
in that case you would select master, press "f" to fetch, and then press
"r" to rebase onto it. It's very bad if master doesn't stay selected
after fetching.

- **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))
* [ ] Docs (specifically `docs/Config.md`) 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
-->
2024-01-19 09:31:21 +01:00
Stefan Haller 2c9b4770bc Keep same branch selected when refreshing branches
This wasn't necessary before, because the only available branch sorting option
was by recency, so the sort order couldn't change except by checking out
branches. Now, you can sort by committer date, so the branch order can change by
fetching; in this case it's important to keep the same branch selected. One
important use case is to rebase the checked-out branch onto master; you select
master, press "f" to fetch it (this can now change its position in the list),
and then press "r" to rebase. To make this work smoothly it's important to keep
master selected after pressing "f".
2024-01-19 09:25:07 +01:00
Stefan Haller 9867180202 Add test showing how branch should stay selected after fetching (but doesn't yet) 2024-01-19 09:23:55 +01:00
Stefan HallerandJesse Duffield cf59b40a1b Fix exit code of run_integration_tests.sh when capturing code coverage data 2024-01-16 18:23:53 +11:00
Stefan HallerandGitHub 53acbc8f18 Fix crash with short branch names (#3219) 2024-01-15 13:28:36 +01:00
Stefan Haller 36e57d16bd Don't try to shorten branch names that are already 3 characters or less
This fixes a potential crash when the available width is very small and the
branch name is one to three characters long.
2024-01-15 13:27:49 +01:00
Stefan Haller f133224683 Double the duration of error toasts
This gives users more time to read them.
2024-01-14 17:45:35 +01:00
Stefan Haller 83337d9fa8 Allow showing Disabled errors as error panel instead of toast 2024-01-14 17:45:35 +01:00
Stefan Haller 84e1d15079 Make DisabledReason a struct
This is a pure refactoring, no change in behavior yet. We'll add another field
to the struct in the next commit.
2024-01-14 17:45:35 +01:00
Stefan Haller 09a24ee97d Use ErrorToast instead of error panel when invoking a disabled command 2024-01-14 17:45:35 +01:00
Stefan Haller 99a3ccde71 Add ErrorToast function 2024-01-14 17:45:35 +01:00
Stefan Haller 8ca8a43968 Make it mandatory to acknowledge toasts in tests 2024-01-14 17:42:03 +01:00
Stefan Haller 9fa43394fe Make it possible to handle toasts in integration tests
Use it in two selected tests to demonstrate what it looks like.
2024-01-14 17:42:03 +01:00
Stefan HallerandGitHub 1ca96bbe5b Fix keybindings for characters involving AltGr on Windows (#3194) 2024-01-10 09:42:30 +01:00
Stefan Haller cb5d0bca1c Bump gocui
... and switch back from stefanhaller's tcell fork to the official tcell. This
basically reverts 7ccb871a45.
2024-01-10 09:39:25 +01:00
Stefan HallerandGitHub ef3d6f4a32 Support insteadOf URL rewriting when opening URLs in browser (#3177) 2024-01-10 09:29:26 +01:00
Stefan Haller b470442a46 Obtain remote URL by calling "ls-remote --get-url" instead of using git config
This has the advantage that it still works when the user has configured aliases
using the insteadOf feature [1].

[1] https://git-scm.com/docs/git-config/2.42.0#Documentation/git-config.txt-urlltbasegtinsteadOf)
2024-01-10 09:24:23 +01:00
Stefan HallerandGitHub bf01c0b00e Allow multiple fetch commands (or fetch and pull) to run concurrently (#3202) 2024-01-10 09:23:22 +01:00
Stefan Haller 76e39af76f Allow multiple fetch commands (or fetch and pull) to run concurrently
Git has a bug [1] whereby running multiple fetch commands at the same time
causes all of them to append their information to the .git/FETCH_HEAD file,
causing the next git pull that wants to use the information to become confused,
and show an error like "Cannot rebase onto multiple branches". This error would
occur when pressing "f" and "p" in quick succession in the files panel, but also
when pressing "p" while a background fetch happens to be running. One likely
situation for this is pressing "p" right after startup.

Since lazygit never uses the information written to .git/FETCH_HEAD, it's best
to avoid writing to it, which fixes the scenarios described above.

However, it doesn't fix the problem of repeatedly pressing "f" quickly on the
checked-out branch; since we call "git pull" in that case, the above fix doesn't
help there. We'll address this separately in another PR.

[1] See https://public-inbox.org/git/xmqqy1daffk8.fsf@gitster.g/ for more
information.
2024-01-10 09:18:38 +01:00
Stefan Haller 5b91cd0cc8 Extract a function fetchCommandBuilder 2024-01-10 09:18:38 +01:00
Stefan Haller 6255728e63 Add a method GitVersion.IsAtLeast 2024-01-10 09:18:38 +01:00
Stefan HallerandGitHub d294d51791 Add command to find base commit for creating a fixup (#3105) 2024-01-10 09:17:29 +01:00
Stefan Haller b35f8776e1 Warn when there are hunks with only added lines
The algorithm works by blaming the deleted lines, so if a hunk contains only
added lines, we can only hope that it also belongs in the same commit. Warn the
user about this.

Note: the warning might be overly agressive, we'll have to see if this is
annoying. The reason is that it depends on the diff context size whether added
lines go into their own hunk or are grouped together with other added or deleted
lines into one hunk. However, our algorithm uses a diff context size of 0,
because that makes it easiest to parse the diff; this results in hunks having
only added lines more often than what the user sees. For example, moving a line
of code down by two lines will likely result in a single hunk for the user, but
in two hunks for our algorithm. On the other hand, being this strict makes the
warning consistent. We could consider using the user's diff context size in the
algorithm, but then it would depend on the current context size whether the
warning appears, which could be confusing. Plus, it would make the algorithm
quite a bit more complicated.
2024-01-10 09:11:40 +01:00
Stefan Haller 8ca78412ac Add command to find base commit for creating a fixup 2024-01-10 09:11:40 +01:00
Stefan HallerandGitHub 33f933ba21 Add config setting for splitting window vertically in half screen mode (#3133) 2024-01-09 15:53:32 +01:00
Stefan Haller d70dd5123d Add config setting for side panel location (left or top) in half screen mode 2024-01-09 15:45:26 +01:00
Stefan HallerandGitHub 15da702140 Fix preserving the commit message when description contains blank lines (#3170) 2024-01-09 14:35:43 +01:00
Stefan Haller cd50c79ae4 Preserve the commit message correctly even if the description has blank lines
There are two possible fixes for this bug, and they differ in behavior when
rewording a commit. The one I chose here always splits at the first line feed,
which means that for an improperly formatted commit message such as this one:

   This is a very long multi-line subject,
   which you shouldn't really use in git.

   And this is the body (we call it "description" in lazygit).

we split after the first line instead of after the first paragraph. This is
arguably not what the original author meant, but splitting after the first
paragraph doesn't really work well in lazygit, because we would try to put both
lines into the one-line subject field of the message panel, and you'd only see
the second and not even know that there are more.

The other potential fix would have been to join subject and description with two
line feeds instead of one in JoinCommitMessageAndDescription; this would have
fixed our bug in the same way, but would result in splitting the above message
after the second line instead of the first. I think that's worse, so I decided
for the first fix.

While we're at it, simplify the code a little bit; strings.Cut is documented to
return (s, "") when the separator is not found, so there's no need to do this on
our side.

We do have to trim spaces on the description now, to support the regular reword
case where subject and body are separated by a blank line.
2024-01-09 14:31:53 +01:00
Stefan Haller 3ebba5f32c Add test demonstrating a bug with preserving the commit message
SplitCommitMessageAndDescription splits at the first '\n\n' that it finds (if
there is one), which in this case is between the two paragraphs of the
description. This is wrong.
2024-01-09 14:31:53 +01:00
Stefan Haller 9a423c388d Remove unused function
I think this is a left-over from before we had the new commit message panel. It
no longer makes sense to add a newline to the commit subject.
2024-01-09 14:31:53 +01:00
Stefan Haller daf9b8cfa9 Simplify GetCommitMessage
Use git log instead of git rev-list, this way we don't get a line "commit <sha>"
at the beginning that we then have to discard again.

The test TestGetCommitMsg is becoming a bit pointless now, since it just
compares that input and output are identical.
2024-01-09 14:31:53 +01:00
Stefan HallerandGitHub aeb017e029 Add command to open git difftool (#3156) 2024-01-09 14:29:26 +01:00
Stefan Haller a6174271aa Update cheat sheets and json schema 2024-01-09 14:27:33 +01:00
Stefan Haller 517e0f8248 Add command to open git difftool 2024-01-09 14:27:33 +01:00
Stefan Haller c1cb95db6f Remove unused function 2024-01-09 14:24:14 +01:00
Stefan HallerandGitHub 966e5f5337 Fix checking out a tag when there is a branch with the same name (#3179) 2024-01-09 14:23:08 +01:00
Stefan Haller f244ec8251 Fix checking out a tag when a branch with the same name exists 2024-01-09 14:18:35 +01:00
Stefan Haller 2b97f0fb43 Add test demonstrating the problem
When there's a branch with the same name as the tag, the branch gets checked out
instead of the tag.
2024-01-09 14:18:35 +01:00
Stefan HallerandGitHub af5e25cfb5 Replace copy commit SHA with copy commit subject on the y s keybind in the commits view (#3188) 2024-01-09 14:17:05 +01:00
Stefan HallerandGitHub d97b37a178 Add local branch sorting menu (#3182) 2023-12-27 15:30:25 +01:00
Stefan HallerandGitHub 470632b97a Add age to stash entries (#3174) 2023-12-27 11:23:57 +01:00
Stefan HallerandGitHub 85c48ba887 Add remote branch sorting menu, saving the option to state.yml (#3171) 2023-12-22 09:16:34 +01:00
Stefan HallerandAlex March 1e3935cbaf Add integration test for remote branch sort order 2023-12-22 16:30:20 +09:00
Stefan HallerandGitHub 4ee01d153b fix(config): add yaml:"options" struct tag to CustomCommandPrompt.[]Options (#3163) 2023-12-15 16:39:43 +01:00
Stefan HallerandGitHub d548f857a4 Fall back to WithWaitingStatus if item is not visible (#3083) 2023-12-10 16:06:49 +01:00
Stefan Haller f99c59b6d5 Fall back to WithWaitingStatus if item is scrolled out of view 2023-12-10 16:03:25 +01:00
Stefan Haller 0fd4983c66 Fall back to WithWaitingStatus if view showing the item is not visible 2023-12-10 15:57:51 +01:00
Stefan Haller 240948b882 Return only visible views from TopViewInWindow
Without this it's not reliably possible to ask whether a given view is visible
by asking

  windowHelper.TopViewInWindow(context.GetWindowName()) == context.GetView()

because there could be transient, invisible contexts after it in the Z order.

I guess it's a bit of a coincidence that this has never been a problem so far.
2023-12-10 15:57:51 +01:00
Stefan HallerandGitHub 653e59a3d5 Make move up/down blocking (#2966) 2023-12-09 15:40:23 +01:00
Stefan Haller e342860ef1 Add WithWaitingStatusSync for reverting commits 2023-12-09 15:28:41 +01:00
Stefan Haller 569adae6a2 Use WithWaitingStatusSync for move commit up/down 2023-12-09 15:28:40 +01:00
Stefan Haller 79fe885dcd Add WithWaitingStatusSync 2023-12-09 15:28:40 +01:00
Stefan Haller a46f26e148 Bump gocui 2023-12-09 15:23:40 +01:00
Stefan HallerandGitHub ca4b8b25f0 Fix bottom line alignment (#3076) 2023-12-09 11:57:06 +01:00
Stefan Haller 8cc820668a Fix an incorrect comment
It sounds like at some point we only showed a slash as the search prompt, but I
dug a bit through the history and couldn't find a state of the code where that
was the case. (shrug)
2023-12-09 11:18:28 +01:00
Stefan HallerandGitHub a8a4211d2b Add a copy-to-clipboard menu to the file view (with diff copy options) (#3104) 2023-12-07 08:35:28 +01:00
Stefan HallerandGitHub 1555503493 Add UserConfig jsonschema generation script (#3039) 2023-12-02 13:27:37 +01:00
Stefan HallerandGitHub b123719107 Update cheatsheets (#3143) 2023-12-02 10:41:08 +01:00
Stefan Haller 6ec109c15a Update cheatsheets
This was forgotten in #3046.
2023-12-02 10:36:15 +01:00
Stefan HallerandGitHub d8059d7f7d Use a PTY when calling external diff command (#3120) 2023-11-22 12:51:02 +01:00
Stefan HallerandGitHub 4a5b3eaa52 Fix go.mod file (#3118) 2023-11-19 17:10:03 +01:00
Stefan Haller 1b4e76797f Add "go mod tidy" check to CI
This should catch errors like this earlier.
2023-11-18 16:03:51 +01:00
Stefan Haller 58971182ca Fix go.mod file (go-difflib dependency should be indirect)
This broke with commit 7af371701d, but nobody noticed yet.
2023-11-18 16:01:03 +01:00
Stefan HallerandGitHub df8ce76bd6 Update Stacked_Branches.md (#3090) 2023-10-24 17:26:49 +02:00
Stefan HallerandGitHub c4fc30c243 Truncate branch names to make branch status always visible (#3075) 2023-10-16 13:30:24 +02:00
Stefan Haller 117aa1dcc6 Advise developers to use a nerd font in their editor 2023-10-16 13:15:05 +02:00
Stefan Haller c550737a4f Truncate long branch names to make branch status visible 2023-10-16 13:15:05 +02:00
Stefan Haller 9e37ae3f5d Make the window a little wider for headless integration tests
100 was an unrealistically narrow width; make it a little wider so that we will
have to truncate things less often.
2023-10-16 09:03:07 +02:00
Stefan Haller c89ef8b84a Make it possible to set the nerd fonts version to "off"
We don't need this for production code, but it will be needed for tests in the
next commit.
2023-10-16 09:03:07 +02:00
Stefan Haller 23befdd13a Pass "now" into utils.Loader
This makes it possible to write deterministic tests for views that use it.
2023-10-16 09:03:07 +02:00
Stefan Haller 58a83b0862 Remove special code to rerender views on screen mode change
The previous commit handles this case too.
2023-10-16 09:03:07 +02:00
Stefan Haller d5b4f7bb3e Rerender certain views when their width changes
Situations where a view's width changes:
- changing screen modes
- enter staging or patch building
- resizing the terminal window

For the first of these we currently have special code to force a rerender, since
some views render different content depending on whether they are in full-screen
mode. We'll be able to remove that code now, since this new generic mechanism
takes care of that too.

But we will need this more general mechanism for cases where views truncate
their content to the view width; we'll add one example for that later in this
branch.
2023-10-16 09:03:07 +02:00
Stefan HallerandGitHub f609a04671 Add 'lvim' editor preset for lunarvim (#3074) 2023-10-15 09:46:30 +02:00
Stefan HallerandGitHub 3691856021 Re-apply filter when model changes (#3058) 2023-10-10 08:43:48 +02:00
Stefan Haller b5ca6a3add When refreshing models, re-apply active filter for the corresponding view 2023-10-10 08:37:30 +02:00
Stefan HallerandGitHub ecaa4846f1 Fix crash when trying to filter the list of remotes (#3059) 2023-10-10 08:36:47 +02:00
Stefan Haller 787f9966ec Fix crash when trying to filter the list of remotes
This seems to be a left-over from an earlier iteration of the code. Removing it
fixes the crash.
2023-10-10 08:33:18 +02:00
Stefan HallerandGitHub 013cfc77a1 Show sync status in branches list (#3021) 2023-10-10 08:32:42 +02:00