1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-21 12:16:54 +02:00

5426 Commits

Author SHA1 Message Date
Stefan Haller
dbdabb34f3 Make "Find base commit for fixup" work with hunks with only added lines
To understand what this does and why, read the design document that I'm about to
add in the next commit.
2024-06-01 08:31:18 +02:00
Stefan Haller
c1a65546ad Extract a function findCommit
It's not much code, but it turns three lines of code into one, and since we need
to do this a few more times in the next commit, it's worth it.
2024-06-01 08:31:18 +02:00
Stefan Haller
2c9bca8b57 Return errors from blameDeletedLines instead of just logging them
I guess when I originally wrote this code I just didn't know how to do that...
2024-06-01 08:31:18 +02:00
Stefan Haller
880528b2e4 Also return hunks with only added lines from parseDiff
We aren't using them, yet, except for deciding whether to show the warning about
hunks with only added lines.

Add a bit of test coverage for parseDiff while we're at it.
2024-06-01 08:31:18 +02:00
Stefan Haller
e1b4d625c7 Make parseDiff a non-member function so that we can test it more easily 2024-06-01 08:31:18 +02:00
Stefan Haller
a957c5542f Rename deletedLineInfo to hunk
We'll use it with a more general meaning later in this branch.
2024-06-01 08:31:18 +02:00
Stefan Haller
f085d10c46
Add user config gui.expandedSidePanelWeight (#3623)
- **PR Description**

Add a user config `gui.expandedSidePanelWeight` which lets you change
the default weight of 2 that gets assigned to the expanded side panel if
`expandFocusedSidePanel` is true.

Closes #3621.

- **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))
* [x] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
2024-06-01 08:25:30 +02:00
Stefan Haller
1269938ee6 Add user config expandedSidePanelWeight 2024-06-01 08:21:23 +02:00
Stefan Haller
557dfc5a6d Add test for ExpandFocusedSidePanel config 2024-06-01 08:16:06 +02:00
Stefan Haller
c5baa5da3a
Fix pushing to branch when upstream not stored locally (#3619)
- **PR Description**

This fixes three different problems; two were recent regressions, one
has never worked.

1. For branches whose remote is not stored locally, don't ask to force
push right away. Try a normal push first. This broke with #3528.
2. For branches whose remote is not stored locally (but only for those),
if the server rejects the update, ask to force push. This broke with
#3387.
3. When force-pushing a branch whose remote is not stored locally, use
`--force` instead of `--force-with-lease`; otherwise the push would
always fail with a "stale info" error. This has never worked.

Fixes #3588.
2024-06-01 08:15:35 +02:00
Stefan Haller
3284d69886 Add integration test for pushing when the remote is not stored locally
The test needs all three fixes from this branch to succeed.
2024-06-01 08:12:45 +02:00
Stefan Haller
116c18e957 Use --force instead of --force-with-lease when remote is not stored locally
--force-with-lease simply doesn't work in this case, it will always return a
"stale info" error.
2024-06-01 08:12:45 +02:00
Stefan Haller
e93617b1de Rename Force to ForceWithLease
This describes better what it is, and we're going to add the regular --force in
the next commit.

No change in behavior in this commit.
2024-06-01 08:12:45 +02:00
Stefan Haller
aac2535104 Ask to force push if server rejected the update, if remote not stored locally
This broke with 81b497d186 (#3387). In that PR I claimed that we never want to
ask for force-pushing if the server rejected the update, on the assumption that
this can only happen because the remote tracking branch is not up to date, and
users should just fetch in this case. However, I didn't realize it's even
possible to have a branch whose upstream branch is not stored locally; in this
case we can't tell ahead of time whether a force push is going to be necessary,
so we _have_ to rely on the server response to find out. But we only want to do
that in this specific case, so this is not quite an exact revert of 81b497d186.
2024-06-01 08:12:45 +02:00
Stefan Haller
993d66a8ff Don't force-push if the remote branch is not stored locally
This broke with #3528.

If the remote branch is not stored locally, we only see question marks in the
branch status. In this case we can't tell whether we need to force-push, so it's
best to assume that we don't, and see if the server rejects the push, and react
to that by asking to force push. This second part is also broken right now,
we'll fix this in the next commit.
2024-06-01 08:12:45 +02:00
Stefan Haller
ab797fe986
Fix boolean config keys not appearing in the generated Config.md (#3622)
- **PR Description**

All boolean config keys were missing from the generated Config.md.

- **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 have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
2024-05-31 21:29:17 +02:00
Stefan Haller
4bfda1a78c Fix boolean config keys not appearing in the generated Config.md
The reason why they didn't appear is that they didn't get a default value in the
generated schema; this commit fixes that.
2024-05-31 20:07:58 +02:00
Stefan Haller
91cb33db85 Remove an outdated comment
Lazygit doesn't touch this, the comment is just not true.

I wonder if we need the config at all, actually; I'd be in favor of removing it.
2024-05-31 20:05:44 +02:00
Stefan Haller
7492521829
Improve branch and reflog loading when sorting branches by date (#3609)
- **PR Description**

When branches are sorted by recency we have this logic that first loads the
branches so that they can be rendered quickly; in parallel, it starts loading
the reflog in the background, and when that's done, it loads the branches again
so that they get their recency values. This means that branches are loaded twice
at startup.

We don't need this logic when branches are not sorted by recency, so we can
simply load branches and reflog in parallel like everything else.

This shouldn't change any user observable behavior, it just avoids doing
unnecessary work at startup.
2024-05-29 13:50:02 +02:00
Stefan Haller
35af886f55 Refresh branches and reflog independently when sorting branches by date
When branches are sorted by recency we have this logic that first loads the
branches so that they can be rendered quickly; in parallel, it starts loading
the reflog in the background, and when that's done, it loads the branches again
so that they get their recency values. This means that branches are loaded twice
at startup.

We don't need this logic when branches are not sorted by recency, so we can
simply load branches and reflog in parallel like everything else.

This shouldn't change any user observable behavior, it just avoids doing
unnecessary work at startup.
2024-05-29 13:46:53 +02:00
Stefan Haller
f45ecbc19a Fix out-of-date comment
The behavior described in the comment is no longer what we do, it was changed in
ae66f720f5; we now always reuse the state.
2024-05-29 13:46:53 +02:00
Stefan Haller
51eb6d7c7d
Pin golangci version to 1.58 (#3611)
Pin golangci version to 1.58.

It is annoying when CI builds suddenly start to fail because the linter
was updated and finds new things to complain about.

Updating the linter and fixing the code accordingly should be a
dedicated activity.
2024-05-29 13:46:19 +02:00
Stefan Haller
38ec4e646f Pin golangci version to 1.58
It is annoying when CI builds suddenly start to fail because the linter was
updated and finds new things to complain about.

Updating the linter and fixing the code accordingly should be a dedicated
activity.
2024-05-29 13:42:11 +02:00
Stefan Haller
ef1daf314a
Fix tooltip for fixup command (#3601)
### PR Description

- Fix calculation of tooltip height; for tooltips that are just one or
two characters longer than the available width, the last word would be
cut off. On my screen this happened for the tooltip for the fixup
command.
- Fix tooltip of fixup command.

Fixes #3600.
2024-05-27 07:53:16 +02:00
Stefan Haller
ab643749e8 Fix tooltip of fixup command 2024-05-26 19:30:38 +02:00
Stefan Haller
2d0c96466a Fix calculation of tooltip height
For tooltips that are just one or two characters longer than the available
width, the last word would be cut off. On my screen this happened for the
tooltip for the fixup command.
2024-05-26 19:26:27 +02:00
Jesse Duffield
f6ace8380f Update readme 2024-05-26 14:35:38 +10:00
Stefan Haller
b4aa68d0b3
Delete the TODO comment about enabling goconst in the future from .golangci.yml (#3596)
## Context:

https://github.com/jesseduffield/lazygit/pull/3592#issuecomment-2129535231
2024-05-24 15:40:41 +02:00
kyu08
4a97fb80f3 Delete the TODO comment about enabling goconst in the future from .golangci.yml 2024-05-24 22:29:44 +09:00
Stefan Haller
8f1a04d095
Add lint to make target (#3593)
I feel this is necessary when I worked on
https://github.com/jesseduffield/lazygit/pull/3592.
2024-05-24 12:57:47 +02:00
kyu08
e5f4de8d34 Add lint to make target 2024-05-24 12:54:45 +02:00
Stefan Haller
ce3fe37787
Add copyloopvar to enabled linters (#3586)
Resolves #3573 
It looks like the update to go1.22 is done by
https://github.com/jesseduffield/lazygit/pull/3574. So it should be OK
to close #3573 when this PR is merged.

## PR Description
Add [`copyloopvar`](https://github.com/karamaru-alpha/copyloopvar) to
enabled linters to detect unnecessary assignments in `for` loops.

## Context
@jesseduffield and I were talking about necessity of this linter here.
https://github.com/jesseduffield/lazygit/issues/3573#issuecomment-2123732829
2024-05-24 11:03:01 +02:00
kyu08
6cf6941a77 Add copyloopvar to enabled linters 2024-05-22 21:57:34 +09:00
Stefan Haller
0fbed71f15
Add property outputTitle to CustomCommand (#3579)
- **PR Description**

Add property `outputTitle` to CustomCommand. It can optionally be used
to set the title of the panel that shows the output of a command (when
`showOutput` is true). If left unset, the command string is used as the
title.

Closes #3576.
2024-05-20 21:05:58 +02:00
Stefan Haller
22a38c9f50 Add property outputTitle to CustomCommand
It can optionally be used to set the title of the panel that shows the output of
a command (when showOutput is true). If left unset, the command string is used
as the title.
2024-05-20 21:02:49 +02:00
Stefan Haller
6343fb57d6
Focus on local commits view after moving code into new commit (#3577)
- **PR Description**

This PR forces lazygit to focus to the `Commits` view after moving a
custom (partial) patch in a new commit.

This closes #3200.
2024-05-20 20:58:31 +02:00
AzraelSec
5af0ea85fc feat: focus on local commits view after moving code into new commit 2024-05-20 19:12:38 +02:00
Stefan Haller
a4e9181a6b
Remove hint about Config.md from PR template (#3578)
It used to be a common thing to have to update `Config.md` in a PR (and
we often forgot despite the template). As of #3565 this is no longer
necessary, so remove this from the template.

Updating docs in general is still a good thing to think about, so we
leave this in.
2024-05-20 07:01:30 +02:00
Stefan Haller
f5d57f7cc7 Remove hint about Config.md from PR template
It used to be a common thing to have to update Config.md in a PR (and we often
forgot despite the template). As of #3565 this is no longer necessary, so remove
this from the template.

Updating docs in general is still a good thing to think about, so we leave this
in.
2024-05-20 06:59:22 +02:00
Jesse Duffield
fc7b10f557
Update README.md
Updated the company sponsors with the new name of my company
2024-05-20 12:21:07 +10:00
Stefan Haller
b75c177c31
Add default lazygit config generation in Config.md from JSON schema (#3565)
- **PR Description**
This uses the JSON schema generated in
https://github.com/jesseduffield/lazygit/pull/3039 to generate and
replace the default lazygit config in Config.md when running `go
generate ./...`

Relevant issue: https://github.com/jesseduffield/lazygit/issues/3441

The generated config contains all the entries that have default values
set in `user_config.go`
2024-05-19 14:11:23 +02:00
Karim Khaleel
9b152d7619 Make Keybindings definition in UserConfig struct last
This makes the generated default config in Config.md match the original
order.
2024-05-19 14:08:27 +02:00
Karim Khaleel
b98ae1c773 Add default lazygit config generator for Config.md from JSON schema 2024-05-19 14:08:05 +02:00
Karim Khaleel
7d787afb2c Set default value for WindowSize config to pass validation 2024-05-19 14:07:51 +02:00
Karim Khaleel
af842e40d4 Remove unnecesary schema validations in user config 2024-05-19 14:07:40 +02:00
Stefan Haller
6fcb7eb8bb
Correctly request force-pushing in a triangular workflow (#3528)
- **PR Description**

Some people push to a different branch (or even remote) than they pull
from. One example is described in #3437. Our logic of when to request a
force push is not appropriate for these workflows: we check the
configured upstream branch for divergence, but that's the one you pull
from. We should instead check the push-to branch for divergence.

Fixes #3437.
v0.42.0
2024-05-19 10:00:32 +02:00
Stefan Haller
c5cf1b2428 Correctly request force-pushing in triangular workflows
To determine whether we need to ask for force pushing, we need to query the push
branch rather than the upstream branch, in case they are not the same.
2024-05-19 09:44:38 +02:00
Stefan Haller
d890c68cd0 Add ahead/behind information for @{push}
In a triangular workflow the branch that you're pulling from is not the same as
the one that you are pushing to. For example, some people find it useful to set
the upstream branch to origin/master so that pulling effectively rebases onto
master, and set the push.default git config to "current" so that "feature"
pushes to origin/feature.

Another example is a fork-based workflow where "feature" has upstream set to
upstream/main, and the repo has remote.pushDefault set to "origin", so pushing
on "feature" pushes to origin/feature.

This commit adds new fields to models.Branch that store the ahead/behind
information against the push branch; for the "normal" workflow where you pull
and push from/to the upstream branch, AheadForPush/BehindForPush will be the
same as AheadForPull/BehindForPull.
2024-05-19 09:44:38 +02:00
Stefan Haller
0aba686f97 Rename Pushables/Pullables to AheadForPull/BehindForPull
In preparation for adding AheadForPush/BehindForPush in the next commit.
2024-05-19 09:44:38 +02:00
Stefan Haller
b91b40ba4d Add test demonstrating the problem with force-pushing in a triangular workflow
Our code doesn't realize that we need to prompt the user to force push, when the
branch is up-to-date with its upstream but not with the branch that we're
pushing to.
2024-05-19 09:44:38 +02:00