Commit graph

5390 commits

Author SHA1 Message Date
Jesse Duffield
3dc960b475 fixup! Factor out CommitLoader.mainBranches into its own class, and store it in Model 2024-05-19 17:24:19 +10:00
Jesse Duffield
de7ee9af21 Use one worker per branch to speed things up 2024-05-19 17:23:39 +10:00
Stefan Haller
eded3ccf54 Add command "Rebase onto base branch" to rebase menu 2024-05-19 17:23:39 +10:00
Stefan Haller
b3252ee7c8 Remove target branch from title of rebase menu
Put it into the individual menu items instead.

Again, this is necessary because we are going to add another entry to the menu
that is independent of the selected branch.
2024-05-19 17:23:39 +10:00
Stefan Haller
f2e8e3fcc1 Always show rebase menu, even when rebasing is not possible
Instead, disable the individual entries in the menu.

This is necessary because we are going to add another entry to the menu that is
independent of the selected branch.
2024-05-19 17:23:39 +10:00
Stefan Haller
7acf96bd0d Make "Rebase" show up with "..." in the keybindings menu 2024-05-19 17:23:39 +10:00
Stefan Haller
9ede2f025e Fix typo 2024-05-19 17:23:39 +10:00
Stefan Haller
f58b7da7dc Add command "View divergence from base branch" 2024-05-19 17:23:39 +10:00
Stefan Haller
b23ea3b190 fixup! WIP Add showDivergenceFromBaseBranch config 2024-05-19 17:23:39 +10:00
Stefan Haller
4d2177725f WIP Add showDivergenceFromBaseBranch config 2024-05-19 17:23:39 +10:00
Stefan Haller
6d2ec43596 WIP Show both ahead and behind 2024-05-19 17:23:39 +10:00
Stefan Haller
6eaece3696 Show divergence from base branch in branches list 2024-05-19 17:23:39 +10:00
Stefan Haller
316ea99d67 Add GetBaseBranch function 2024-05-19 17:23:39 +10:00
Stefan Haller
e7ac70c415 Remove ColoredBranchStatus and branchStatusColor
Previously the entire status was colored in a single color, so the API made
sense. This is going to change later in this branch, so now we must include the
color in the string returned from BranchStatus(), which means that callers who
need to do hit detection or measure the length need to decolorize it.

While we're at it, switch the order of ↑3↓7 to ↓7↑3. For some reason that I
can't really explain I find it more logical this way. The software out there is
pretty undecided about it, it seems: VS Code puts ↓7 first, and so does the
shell prompt that comes with git; git status and git branch -v put "ahead" first
though. Shrug.
2024-05-19 17:23:39 +10:00
Stefan Haller
aba0290e51 Factor out CommitLoader.mainBranches into its own class, and store it in Model 2024-05-19 17:23:39 +10:00
Stefan Haller
2ae1bea20a More explicit test of status panel content
Use Equals instead of Contains for asserting the status view content. This
solves the problem that we might assert Contains("↓2 repo"), but what it really
shows is "↑1↓2 repo", and the test still succeeds. At best this is confusing.

Also, this way we don't have to use the awkward DoesNotContain to check that it
really doesn't show a checkmark.

To do this, we need to fix two whitespace problems:
- there was always a space at the end for no reason. Simply remove it. It was
  added in efb51eee96, but from looking at that diff it seems it was added
  accidentally.
- there was a space at the beginning if the branch status was empty. This is
  actually a cosmetic problem, for branches without a status the text was
  indented by once space. Change this so that the space is added conditionally.
  It's a bit awkward that we have to use Decolorise here, but this will go away
  again later in this branch.
2024-05-19 17:23:07 +10:00
Jesse Duffield
9fc7a5177b
Bump go version to 1.22 (#3574)
- **PR Description**

Bumps go from 1.21 to 1.22, and removes newly redundant loop variable
re-declarations now that in 1.22 the variables are automatically
redeclared in each iteration for us.

- **Please check if the PR fulfills these requirements**

* [ ] Cheatsheets are up-to-date (run `go generate ./...`)
* [ ] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [ ] 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
* [ ] 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-05-19 17:22:42 +10:00
Jesse Duffield
fdff2dec79 Remove redundant variable dedeclarations
In go 1.22, loop variables are redeclared with each iteration of the
loop, rather than simple updated on each iteration. This means that we
no longer need to manually redeclare variables when they're closed over
by a function.
2024-05-19 16:38:21 +10:00
Jesse Duffield
9124d8dbaa Bump go version to 1.22 2024-05-19 16:38:21 +10:00
Jesse Duffield
4404aacdee
README.md: Update Sponsors (#3503)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action
2024-05-19 16:15:32 +10:00
github-actions[bot]
8f5ce14dc0 README.md: Update Sponsors 2024-05-19 05:09:25 +00:00
Stefan Haller
866e80529b
Delete and edit custom commands history items (#3534)
- **PR Description**

Allow deleting and editing custom command history items. Deleting is
done by hitting `d` on a suggestion; editing is done by hitting `e`,
which fills the selected item into the command prompt for further
editing.

Closes #2528.
2024-05-19 07:09:13 +02:00
Stefan Haller
010b0ae923 Show delete/edit keybindings in suggestions subtitle if available 2024-05-19 07:06:18 +02:00
Stefan Haller
a7041cf492 Allow editing a custom command from the suggestions list by pressing 'e'
For custom commands it is useful to select an earlier command and have it copied
to the prompt for further editing. This can be done by hitting 'e' now.

For other types of suggestion panels we don't enable this behavior, as you can't
create arbitrary new items there that don't already exist as a suggestion.
2024-05-19 07:06:18 +02:00
Stefan Haller
da3e0f7147 Support deleting items from the custom commands history
In the custom commands panel you can now tab to the suggestions and hit 'd' to
delete items from there. Useful if you mistyped a command and don't want it to
appear in your history any more.
2024-05-19 07:06:18 +02:00
Jesse Duffield
269d01233f
Improve nvim-remote mode (#3508)
- If _not_ inside a neovim session, treat as a normal nvim invocation
and suspend lazygit.

- If inside a neovim session:
  - Do not try to suspend lazygit.
  - Send `q` keystroke to neovim session to quit lazygit.
  - Send filename/line/etc. to neovim session.

- **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))
* [ ] 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-05-19 14:42:47 +10:00
Charlie Moog
615ff09afa improve nvim-remote mode
- If _not_ inside a neovim session, treat as
  a normal nvim session and suspend lazygit.

- If inside a neovim session:
  - Do not try to suspend lazygit.
  - Send `q` keystroke to neovim session to quit lazygit.
  - Send filename/line/etc. to neovim session.
2024-05-19 14:39:02 +10:00
Jesse Duffield
772388294a
Attempt #2 at preventing codacy coverage step from running on forks (#3572)
- **PR Description**

First attempt didn't work. Let's try this one, based on
https://github.com/orgs/community/discussions/25217

<img width="910" alt="image"
src="fa2e82b0-db34-486b-8bea-ec3807d10a33">

- **Please check if the PR fulfills these requirements**

* [ ] Cheatsheets are up-to-date (run `go generate ./...`)
* [ ] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [ ] 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
* [ ] 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-05-19 14:38:48 +10:00
Jesse Duffield
e09b38153c Attempt #2 at preventing codacy coverage step from running on forks 2024-05-19 14:36:25 +10:00
Jesse Duffield
cd62c719f1
Only run code coverage report on non-fork branches (#3571)
- **PR Description**

Codacy's coverage report feature requires the use of a secret key, which
is only available on the main repo and is not available on forks. So,
the step has been always failing on any forks. This commit ensures that
we only run it on non-forks.

This greatly diminishes the value of the coverage reports. I've talked
to one of the Codacy people and advised that they should just have an
API key for coverage reports which is not a secret, like what bugsnag
does.

I've disabled the gate in codacy meaning if the coverage ever drops
beneath some percentage, the job won't fail. It wouldn't make sense to
fail the job if some other PR from a fork was responsible for reducing
the coverage percentage beneath some threshold.

- **Please check if the PR fulfills these requirements**

* [ ] Cheatsheets are up-to-date (run `go generate ./...`)
* [ ] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [ ] 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
* [ ] 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-05-19 14:10:16 +10:00
Jesse Duffield
36e7524146 Only run code coverage report on non-fork branches
Codacy's coverage report feature requires the use of a secret key, which
is only available on the main repo and is not available on forks. So,
the step has been always failing on any forks. This commit ensures that
we only run it on non-forks.

This greatly diminishes the value of the coverage reports. I've talked
to one of the Codacy people and advised that they should just have an
API key for coverage reports which is not a secret, like what bugsnag
does.
2024-05-19 14:05:30 +10:00
Stefan Haller
189f39de2b
Fix Stashing partial files for git version >= 2.35.0 (#3569)
- **PR Description**
Use git's `--staged` flag to stash staged changes if available (requires
git 2.35.0 or later), and fall back to our previous method if not. This
is a lot faster than our previous method, and it fixes two bugs, see
linked issues.

Fixes #3333 and #3563.

- **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
2024-05-18 10:07:24 +02:00
dsolerhww
5b80c0c792 Fix stashing partialy staged files for git version >= 2.35.0
Use `git stash push --staged` git feature available on git version >
2.35.0.
2024-05-18 09:59:00 +02:00
Stefan Haller
d8b3c0e568
Fix loading commits with very long subjects (#3533)
- **PR Description**

This PR fixes a problem with lazygit locking up completely when there's
a commit whose subject line is longer than approximately 65500
characters.

Fixes #3529.
2024-05-15 13:29:28 +02:00
Stefan Haller
f69eb6dc48 Use ScanLinesAndTruncateWhenLongerThanBuffer instead of bufio.ScanLines 2024-05-15 13:27:01 +02:00
Stefan Haller
e0a2d97f0f Put subject last in git log's prettyFormat
We are going to truncate overly long lines returned from git log, and the most
likely field that is going to make the line too long is the subject; so we must
put it last, otherwise we'd end up with not enough fields to split when it's too
long.

It might not be obvious from the diff what's happening to the mock command
output in the test: it didn't have the divergence field (">") at all, which was
kind of a bug. It didn't matter for these tests though, because we are not
testing the divergence here, and our production code happens to be resilient
against it missing. But now we must add the ">" field before the subject.
2024-05-15 13:27:01 +02:00
Stefan Haller
66d0ce841c Implement ScanLinesAndTruncateWhenLongerThanBuffer 2024-05-15 13:27:01 +02:00
Stefan Haller
6bb8c180b2 Handle scanner error in RunAndProcessLines
Scanners can return errors (e.g. ErrTooLong), and if we don't handle it, the
cmd.Wait() call below will block forever because nobody drains the command's
output.

This happens for CommitLoader.GetCommits when there's a commit whose subject
line is longer than approx. 65500 characters; in that case, lazygit would lock
up completely. With this fix it remains usable, but the commit list is truncated
before the bad commit, which is not good enough. We'll improve that in the
remaining commits of this branch.
2024-05-15 13:27:01 +02:00
Stefan Haller
5558d873af
Fix clicking in status side panel (#3547)
- **PR Description**

Clicking in the status side panel should activate it; also, clicking on
the repo name should bring up the recent repositories menu, and clicking
on the "(rebasing)" text should bring up the rebase options menu. All of
this was broken for a long time, since somewhere around the big
refactoring of March 2023. (The exact commit where it broke is hard to
bisect, since many of the commits in that area either don't compile or
crash at startup...)

I'm fixing this not because I think it's super important functionality
(nobody seems to have missed it for over a year), but because I have to
touch this code in another PR, and noticed that it wasn't working.

- **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
2024-05-15 13:24:07 +02:00
Stefan Haller
380855d4e8 Add tests for clicking in status side panel
To prevent this from breaking again. All three tests would fail without the fix
from the previous commit.
2024-05-15 13:21:17 +02:00
Stefan Haller
88e7c44552 Fix clicking in status side panel
Seems to have been broken since that big refactoring in March 23.
2024-05-15 13:21:17 +02:00
Stefan Haller
ac0524f7cb
Fix deadlock reporting (#3550)
Deadlock reporting broke in e1ceb6892a (last September); since then, it
was *off* when running debug builds normally, but *on* when debugging an
integration test. Both of which are exactly opposite of what we want.
2024-05-15 13:19:41 +02:00
Stefan Haller
10e29ce7dd Fix deadlock reporting
Deadlock reporting broke in e1ceb6892a; since then, it was *off* when running
debug builds normally, but *on* when debugging an integration test. Both of
which are exactly opposite of what we want.
2024-05-05 15:23:58 +02:00
Stefan Haller
618fe533f8
Add commitPrefix for defining a prefix for any project (#3291)
- **PR Description**

Adds a new option `git.comitPrefix` to act similarly to
`git.commitPrefixes`, except, if defined, it applies to any repo that
doesn't have an entry in `git.commitPrefixes`.

- **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
2024-05-01 19:12:53 +02:00
Jonathan Duck
01ff18dd92 Add commitPrefix for defining a prefix for any project 2024-05-01 19:03:12 +02:00
Stefan Haller
af0897f18f
Enable the commit graph in the divergence view (#3537)
- **PR Description**

In the "View divergence from upstream" view we have so far disabled the
commit graph because it was too difficult to implement properly. I
really miss it though, so here's a PR that enables it there, too.

For feature branches it is not essential, because these usually don't
contain merges and the graph is a trivial line. However, for the master
branch against its upstream it is useful too see how many PRs were
merged since you last fetched it, and the graph helps a lot with that.
Also, when we implement #3536 it will be very useful there, too.
2024-04-30 13:53:35 +02:00
Stefan Haller
b7673577a2 Enable the commit graph in the divergence view 2024-04-30 13:50:46 +02:00
Stefan Haller
00c55d5711
chore: fix some comments and typos (#3535)
- **PR Description**
fix some comments and typos
2024-04-28 10:02:59 +02:00
knowmost
0677a58e9f chore: fix some comments and typos
Signed-off-by: knowmost <knowmost@outlook.com>
2024-04-28 09:44:59 +02:00
Stefan Haller
b3a60ce407
Add config options for length of commit hash displayed in commits view (#3505)
- **PR Description**

Add a new config option `gui.commitHashLength` to change the length of
the commit hash displayed in commits view.

default:
<img width="472" alt="image"
src="36dced1e-0c74-4dbd-8670-98e17a75d83a">

With config:
```yaml
gui:
  commitHashLength: 3
```
<img width="463" alt="image"
src="e8023cd8-f138-4af8-ae0e-3661f80206ca">


- Changes
- Added the user config option to to `pkg/config/user_config.go` and
`schema/config.json`
  - documented in `docs/Config.md`
- Changed the code that displays the hash in
`pkg/gui/presentation/commits.go`
  
---

- **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))
* [ ] 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))
* [x] Docs (specifically `docs/Config.md`) have been updated if
necessary
* [x] You've read through your own file changes for silly mistakes etc
2024-04-28 08:22:48 +02:00