1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-22 15:22:51 +03:00

6368 Commits

Author SHA1 Message Date
Stefan Haller
d102f12304 Make HandleGenericClick a little smarter
Make it recognize URLs wrapped in angle brackets, and followed by punktuation.
We don't need this for the status panel, but we will need it for confirmation
panels.
2024-03-29 10:55:33 +01:00
Stefan Haller
6396d1ce03 Extract a function HandleGenericClick 2024-03-29 10:55:33 +01:00
Stefan Haller
c59e6b6451 Cleanup: don't mess with globals in tests without resetting them
Changing globals in the init() function of a test file is a bad idea, as it
affects all other tests that run after it. Do it explicitly in each test
function that needs it, and take care of restoring the previous value
afterwards.
2024-03-29 10:55:33 +01:00
Stefan Haller
1cedfa463b
Fix schema link in Config.md (#3451)
The schema at https://json.schemastore.org/lazygit.json is broken and
doesn't work. It should actually be removed.
2024-03-28 13:31:28 +01:00
Stefan Haller
9b035aed67 Fix schema link in Config.md 2024-03-28 13:24:54 +01:00
Stefan Haller
ce9cdd8d78
Fix rewording signed commits when the log.showsignature git config is true (#3431)
- **PR Description**

For people who have the log.showsignature git config set to true, trying
to reword a signed commit would put the signature verification into the
subject field and the commit subject into the description field of the
commit message panel. Amending commits, adding co-authors to a commit,
and copying a commit message to the clipboard would all be broken in a
similar way.

Slightly related is #1911, but back then it was more about performance
than wrong behavior, it seems.

Fixes #3425.
2024-03-28 13:19:11 +01:00
Stefan Haller
f774b7eb5c Fix rewording signed commits when the log.showsignature git config is true
For people who have the log.showsignature git config set to true, trying to
reword a signed commit would put the signature verification into the subject
field and the commit subject into the description field of the commit message
panel. Amending commits, adding co-authors to a commit, and copying a commit
message to the clipboard would all be broken in a similar way.
2024-03-28 13:16:10 +01:00
Stefan Haller
e4b4b6d5f4
Fix excluding files in submodules or worktrees (#3432)
- **PR Description**

Make the "Add to .git/info/exclude" command work correctly in a worktree
or in a submodule. Previously it would result in an error message.

Fixes #3427.
2024-03-28 13:13:52 +01:00
Stefan Haller
93251db67e Fix the "Add to .git/info/exclude" command in submodules or worktrees 2024-03-28 13:11:08 +01:00
Stefan Haller
de52a68b53 Add a test that demonstrates the problem
Using the "Add to .git/info/exclude" in a worktree results in an error message,
as the test shows. The same would happen in a submodule, but I'm not adding an
extra test for that, as the circumstances are the same.
2024-03-28 13:11:08 +01:00
Stefan Haller
42ebf1947a Cleanup: simplify return statements 2024-03-28 13:11:08 +01:00
Stefan Haller
c995e7ef2e Cleanup: remove pointless condition and error message
The file .git/info/exclude can't possibly show up in the files panel.
2024-03-28 13:11:08 +01:00
Stefan Haller
04fcb78c0c
Keep the same commit selected when exiting filtering mode (#3416)
- **PR Description**

When exiting filtering mode, we currently keep the selection index the
same in the commits panel. This doesn't make sense at all, since the
index in the filtered view has no relation to the index in the
unfiltered view.

I often use filtering mode (either by path or by author) to find a given
commit faster than I would otherwise be able to. When exiting filtering
mode, it's useful to keep the same commit selected, so that I can look
at the surrounding commits, see which branch it was a part of, etc. So
reselect the commit again after exiting filtering mode.

Sometimes this is not possible, most likely when the commit is so long
ago that it's outside of the initial 300 range. In that case, at least
select the commit again that was selected before I entered filtering;
this is still better than arbitrarily keeping the same selection index.
2024-03-28 12:27:02 +01:00
Stefan Haller
bd8518355e Keep the same commit selected when exiting filtering mode
When exiting filtering mode, we currently keep the selection index the same in
the commits panel. This doesn't make sense at all, since the index in the
filtered view has no relation to the index in the unfiltered view.

I often use filtering mode (either by path or by author) to find a given commit
faster than I would otherwise be able to. When exiting filtering mode, it's
useful to keep the same commit selected, so that I can look at the surrounding
commits, see which branch it was a part of, etc. So reselect the commit again
after exiting filtering mode.

Sometimes this is not possible, most likely when the commit is so long ago that
it's outside of the initial 300 range. In that case, at least select the commit
again that was selected before I entered filtering; this is still better than
arbitrarily keeping the same selection index.
2024-03-28 12:23:46 +01:00
Stefan Haller
f93cb54b5d
Fix crash when filtering the keybindings menu (#3450)
- **PR Description**

It would crash when some keybindings are set to null, and the filter
string is such that only those keybindings remain visible.

Fixes #3449.
2024-03-28 12:19:06 +01:00
Stefan Haller
0b70dfbf46 Fix crash when filtering the keybindings menu
It would crash when some keybindings are set to null, and the filter string is
such that only those keybindings remain visible.

The reason for the crash is that when inserting non-model items (menu section
headers in this case) you specify a column to align them to. This works on the
assumption that the number of columns is always the same. It can cope with the
case that columns are removed because they are empty for all items; but it can't
cope with the case that the getDisplayStrings function returns a lower number of
columns.

And this is what happened here: MenuViewModel.GetDisplayStrings would omit the
keybinding column when none of the entries have a keybinding. This logic is
unnecessary, the generic list rendering mechanism takes care of this, so
removing this logic fixes the crash.

We do have to make sure though that the column is really empty when there's no
keybinding, so change the logic to use FgCyan only when there's a keybinding.
2024-03-28 09:58:45 +01:00
Stefan Haller
38876ba141
Update Busy.md (#3433)
- **PR Description**
enqueing -> enqueueing
2024-03-26 23:12:49 +01:00
Ikko Eltociear Ashimine
57786fbb1f Update Busy.md
enqueing -> enqueueing
2024-03-26 23:08:51 +01:00
Stefan Haller
e295ccefab
Fix deleting update ref todos (#3439)
- **PR Description**

Deleting an update-ref todo in an interactive rebase now behaves as
expected (i.e. it leaves the branch referenced by the update-ref
untouched). Previously it would have deleted the branch referenced by
the update-ref todo when the rebase was continued. See #3418 for more
details.

Fixes #3418.
2024-03-26 22:43:46 +01:00
Stefan Haller
1fdcc29277 Fix deleting update-ref todos
It is a bad idea to read a git-rebase-todo file, remove some update-ref todos,
and write it back out behind git's back. This will cause git to actually remove
the branches referenced by those update-ref todos when the rebase is continued.

The reason is that git remembers the refs affected by update-ref todos at the
beginning of the rebase, and remembers information about them in the file
.git/rebase-merge/update-refs. Then, whenever the user performs a "git rebase
--edit-todo" command, it updates that file based on whether update-ref todos
were added or removed by that edit. If we rewrite the git-rebase-todo file
behind git's back, this updating doesn't happen.

Fix this by not updating the git-rebase-todo file directly in this case, but
performing a "git rebase --edit-todo" command where we set ourselves as the
editor and change the file in there. This makes git update the bookkeeping
information properly.

Ideally we would use this method for all cases where we change the
git-rebase-todo file (e.g. moving todos up/down, or changing the type of a
todo); this would be cleaner because we wouldn't mess with git's private
implementation details. I tried this, but unfortunately it isn't fast enough.
Right now, moving a todo up or down takes between 1 and 2ms on my machine;
changing it to do a "git rebase --edit-todo" slows it down to over 100ms, which
is unacceptable.
2024-03-26 22:29:56 +01:00
Stefan Haller
6da9d55e47 Cleanup: update outdated comment
We used to pass the todo string, but this has changed to instructions a while
ago.
2024-03-26 22:25:43 +01:00
Stefan Haller
ba85f93fb3 Extend delete_update_ref_todo test to actually test what it was supposed to
In the test we simply removed the update-ref todo but didn't make any other
changes to the todos. This should really have kept everything the way it was,
including the other branch head. The fact that the star was gone was really
because of the bug that we are going to fix later in the branch.

Change the test so that it also makes a change before the update-ref todo; this
way we test that the star is gone because we deleted the update-ref, not because
of the bug.

To guard against the bug, we add another assertion for the branches view to test
that both branches are still there. This currently fails.
2024-03-26 22:23:50 +01:00
Stefan Haller
cdbec3997d Cleanup: fix typo in test comment 2024-03-26 22:23:50 +01:00
Stefan Haller
fb675b79f8
Set the TERM env variable (#3420)
Resolves #3419

I have tested this change with all the pagers shown in [the
docs](https://github.com/jesseduffield/lazygit/blob/master/docs/Custom_Pagers.md).
Are there others that people frequently use and I should test?

A nice side effect of setting `TERM=dumb` is that `less` now correctly
complains (e.g. when forgetting to set `--paging=never` for delta:


![image](https://github.com/jesseduffield/lazygit/assets/4602612/33e9c048-6ab0-4196-95f6-86ee8effc873)


## Pagers Tested

### none

![image](https://github.com/jesseduffield/lazygit/assets/4602612/4e408fe6-5f19-4142-9183-de56fd738962)

### Delta

![image](https://github.com/jesseduffield/lazygit/assets/4602612/90dd12fa-ed58-4d49-9f71-da5e57f63a74)

```yaml
git:
  paging:
    colorArg: always
    pager: delta --paging=never
```

#### diff-so-fancy

![image](https://github.com/jesseduffield/lazygit/assets/4602612/930e6b93-904e-49a2-bfc2-9b5d9639f514)

```yaml
git:
  paging:
    colorArg: always
    pager: diff-so-fancy
```

#### ydiff

![image](https://github.com/jesseduffield/lazygit/assets/4602612/c2464f0c-f34f-4ebc-9624-8bc0350d92a7)

```yaml
git:
  paging:
    colorArg: always
    pager: ydiff -p cat
```

#### difft

![image](https://github.com/jesseduffield/lazygit/assets/4602612/599dee7a-6568-40e4-9213-76ba643d651f)

```yaml
git:
  paging:
    externalDiffCommand: difft --color=always
```
2024-03-23 23:49:22 +01:00
Tau
f30be824b3 Set the TERM env variable
This communicates to pagers that we're in a very simple
terminal that they should not expect to have much capabilities.

See #3419
2024-03-23 23:46:37 +01:00
Jesse Duffield
e1c3ef6629
Update README.md 2024-03-23 21:01:19 +11:00
Jesse Duffield
a70bb0a7aa
Update README.md 2024-03-23 20:59:53 +11:00
Jesse Duffield
7718cb009b
Update README.md
Updating for top-level sponsorship stuff
2024-03-23 20:58:02 +11:00
Jesse Duffield
1337a943fe
Update interactive rebase demo (#3392)
**PR Description**

This is in anticipation of the new release which supports range-select.

- **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-03-23 20:48:54 +11:00
Stefan Haller
471ea39758 Fix inline status removal when recording demos 2024-03-23 20:45:51 +11:00
Jesse Duffield
c3f0b5cb4a Update interactive rebase demo
I'm adding an explicit delay between moving the commits and selecting
the next items because otherwise it happens too fast
2024-03-23 20:45:51 +11:00
Stefan Haller
3675570a39
Fix container detection (#3412)
- **PR Description**

Running WSL without a container would be treated as native linux,
causing problems at it would then attempt to use `xdg-open`. This was
caused by `isContainer()` always returning true due to some dubious
conditionals. These have been removed.

The env-var check seems to not be used by lazygit, nor any common
containers, and therefore appears to only exist to manually tell lazygit
to behave as if it were inside of a container. This functionality has
been kept, but the env-var has been changed to be all uppercaps as to
comply with the POSIX standard.

Fixes #2757
Bug introduced in 4d78d76
pre-0.41 v0.41.0
2024-03-22 14:43:31 +01:00
aritmos
68495ea0ee Fix container detection
Running WSL without a container would be treated as native linux, causing problems at it would then attempt to use `xdg-open`.
This was caused by `isContainer()` always returning true due to some dubious conditionals. These have been removed.

The env-var check seems to not be used by lazygit, nor any common containers, and therefore appears to only exist to manually tell lazygit to behave as if it were inside of a container.
This functionality has been kept, but the env-var has been changed to be all uppercaps as to comply with the POSIX standard.

Fixes #2757
Bug introduced in 4d78d76
2024-03-22 13:42:15 +01:00
Stefan Haller
53363b761c
Add config to truncate commit hashes when copying them to the clipboard (#3402)
- **PR Description**

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).
2024-03-22 10:01:43 +01:00
Stefan Haller
96c5cbe34e Change CopiedToClipboard text to start lower-case
It is used in the context "'xyz' copied to clipboard", so it looks weird when it
start uppercase.
2024-03-22 09:59:46 +01:00
Stefan Haller
b8a0473c68 Change toast for copying sha to clipboard to include what was copied
This makes it easier to see that "y, enter" copies the full sha, whereas ctrl-o
copies an abbreviated sha.
2024-03-22 09:58:54 +01:00
Stefan Haller
571141ea7c Change log message for copying sha to the clipboard to include "full"
To make it even clearer that this is different from copying a sha with ctrl-o.
2024-03-22 09:58:54 +01:00
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