Commit graph

6421 commits

Author SHA1 Message Date
Stefan Haller
9b88052a4e Add test demonstrating problem with revert (or cherry-pick) during a rebase
This problem can't happen inside of lazygit itself right now, but this will
change in the future. It will only happen when you stopped in an interactive
rebase on an "edit" entry, and then you perform a revert or cherry-pick
consisting of more than one commit; in this situation lazygit will show a
conflict although there is none.

This is not possible with lazygit yet, as we don't support range-select for
reverting, and we don't use `git cherry-pick` for cherry-picking. Both will
change in the future, so it's good to fix this bug.
2025-04-20 15:55:44 +02:00
Stefan Haller
6b6d881624 Add test to check that an "edit" entry correctly shows a conflict
This works correctly, we are only adding this as a regression test to verify
that the change later in this branch doesn't break it.
2025-04-20 15:55:44 +02:00
Stefan Haller
bb4d03db1f Show todos (and conflicting commit) for cherry-pick and revert 2025-04-20 15:55:44 +02:00
Stefan Haller
687bae48ed Simplify the MergeRebasingCommits call in GetCommits (slightly)
MergeRebasingCommits already merges the rebasing commits into the commits slice
that is passed in, so it doesn't make sense to append the result to commits
again. It isn't a problem, but only because commits is always empty.
2025-04-20 15:55:44 +02:00
Stefan Haller
ff465e2581 Show original todo action instead of "conflict", and show <-- CONFLICT instead
It is useful to see if the conflicted commit was a "pick" or an "edit". What's
more, we're about to add support for showing cherry-picks and reverts, and
seeing that a conflicted commit was a revert is important because its diff is
backwards compared to the diff of the conflicting files in the Files panel.
2025-04-20 15:55:44 +02:00
Stefan Haller
9c8f987934 Use commit.IsTODO instead of comparing Status against models.StatusRebasing
This is equivalent in the current state of the code, but it will no longer be
after the next commit, because we will introduce a new status value
StatusConflicted. And in a later PR we might add yet another value
StatusCherryPicking to distinguish rebase todos from cherry-pick todos; using
commit.IsTODO is a safer way to check whether a commit is any of these.
2025-04-20 15:55:44 +02:00
Stefan Haller
d84ee606e8 Remove unused enum entry StatusSelected 2025-04-20 15:55:44 +02:00
Stefan Haller
3dc045b69c
Continue/abort a conflicted cherry-pick or revert (#4441)
- **PR Description**

This is part one of a four part series of PRs that improve the
cherry-pick and revert experience.

With this first PR we make it possible to continue or abort a
cherry-pick or revert operation, in the same way you can continue or
abort a rebase or merge. Currently this is only relevant for revert,
because lazygit doesn't use git cherry-pick for copying/pasting commits.
This will change in a later PR in this series though, so here we are
already preparing for that.

Fixes #1807
2025-04-20 15:55:11 +02:00
Stefan Haller
90db796f42 Add DisabledReason for rebase options when not rebasing or merging 2025-04-20 15:53:17 +02:00
Stefan Haller
3e5024480d Check for conflicts after reverting a commit
This way we get the usual menu for viewing the conflicts or aborting, like for
rebases.
2025-04-20 15:53:17 +02:00
Stefan Haller
4b3262ab3e Add test for reverting a commit that conflicts
This works already (except that the "you are here" marker is not right yet, but
that's an issue for another PR), just add a test that verifies it.
2025-04-20 15:53:17 +02:00
Stefan Haller
362678e2ef Mention which command is continued in PromptToContinueRebase
When you are in the middle of a rebase, and you cherry-pick a commit which
conflicts, it helps to be clear on whether you are prompted to continue the
cherry-pick or the rebase.
2025-04-20 15:53:17 +02:00
Stefan Haller
542525743c Make WorkingTreeState a struct, and add cherry-picking and reverting states 2025-04-20 15:53:17 +02:00
Stefan Haller
8af8f7754b Move types/enums/enums.go to working_tree_state.go
It looks like enums.go was supposed to be file that collects a bunch of enums,
but actually there's only one in there, and since it has methods, it deserves to
be in a file of its own, named after the type.
2025-04-20 15:53:17 +02:00
Stefan Haller
e1eb95b2b3 Add test for a special situation in rebases involving empty commits
The situation is that you perform a rebase, and one of the commits becomes empty
during the rebase, in a way that couldn't be predicted before the rebase
started. To explain: git rebase has some logic where it immediately discards
commits if it can tell that they already exist in the branch being rebased onto;
it does this by looking at the patch ids of the commits to work out which
commits already exist upstream. But for those commits that become empty even
though there isn't a corresponding commit upstream, git stops with an error, and
lazygit detects this (in CheckMergeOrRebaseWithRefreshOptions) and automatically
continues the rebase.

This all works fine; I'm adding this test because I almost broke this during
development of this branch, so I'm adding it to guard against regressions.
2025-04-20 15:53:17 +02:00
Stefan Haller
b210b4363d Centralize logic regarding WorkingTreeState close to its definition 2025-04-20 15:53:17 +02:00
Stefan Haller
cd36e95a82 Rename RebaseMode to WorkingTreeState
We're about to add more possible values (reverting and cherry-picking), so
working tree state seems like a more suitable name.
2025-04-20 15:53:17 +02:00
Stefan Haller
1a73697546 Simplify the RebaseMode enum
- Remove REBASE_MODE_NORMAL. It is not the "normal" mode anyway, rather a legacy
mode; we have removed support for it in eb0f7e3d02, so there's no point in
representing it in the enum.
- Remove distinction between REBASE_MODE_REBASING and REBASE_MODE_INTERACTIVE;
these are the same now.
- Rename StatusCommands.IsInInteractiveRebase to IsInRebase.
- Remove StatusCommands.RebaseMode; use StatusCommands.IsInRebase instead.
2025-04-20 15:53:17 +02:00
Stefan Haller
37f835244d Use WorkingTreeState instead of RebaseMode in CommitLoader
We want to get rid of RebaseMode, and using the more general WorkingTreeState
will later allow us to also show cherry-pick or revert todos.
2025-04-20 15:53:17 +02:00
Stefan Haller
94fc4d7eb4 Remove rebaseMode field from TestGetCommits scenario
All test cases set it to enums.REBASE_MODE_NONE, so we can simplify things a
little bit by hard-coding that. This makes the changes in the following commits
a little easier.
2025-04-20 15:53:17 +02:00
Stefan Haller
682e54222c Don't wait for debugger in daemon mode
When debugging an integration test that involves some behind-the-scenes
rebasing, the daemon lazygit would also wait for a debugger to attach. This is
very confusing because the test seems to hang; once you figured out what's going
on, it's inconvenient because you need to attach a debugger to the daemon every
time you debug the test.

Now, it would sometimes be useful to be able to debug the daemon itself (whether
inside an integration test, or during normal usage), and I have often wished to
be able to do that. We might introduce an additional env var (and command-line
option?) to enable this; but that's out of scope here.
2025-04-20 15:53:17 +02:00
Stefan Haller
89ba3f2b1a
Fix truncation of branches when scrolling branches panel to the left (#4483)
- **PR Description**

Truncation of long branch names didn't take the horizontal scroll
position into account; when scrolling the panel to the left using `H`,
the long names were truncated way before the right edge of the view.
2025-04-20 15:52:20 +02:00
Stefan Haller
fa9d75835c Rerender views if necessary when scrolling horizontally
If the context says it wants to rerender when its width changes, we must also
rerender when the horizontal scroll position changes.
2025-04-20 15:50:38 +02:00
Stefan Haller
9e3e1a7b3a Fix truncating branches to the right edge of the view when scrolled to the left
When scrolling the view to the left, the available width becomes the width of
the view plus the scroll position.
2025-04-20 15:50:38 +02:00
Jesse Duffield
0236682882
README.md: Update Sponsors (#4281)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action
2025-04-20 18:24:21 +10:00
github-actions[bot]
058699cb71 README.md: Update Sponsors 2025-04-14 08:28:01 +00:00
Jesse Duffield
5f809809dd
Skip date check when release worfklow is manually invoked (#4484)
- **PR Description**

I just tried creating a release manually and hit an error because it
wasn't the first saturday of the month.

- **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))
* [ ] If a new UserConfig entry was added, make sure it can be
hot-reloaded (see
[here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig))
* [ ] Docs 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
-->
2025-04-14 18:27:49 +10:00
Jesse Duffield
f7eb9113f3 Skip date check when release worfklow is manually invoked 2025-04-14 18:24:45 +10:00
Jesse Duffield
d68c116387
Escape special characters in filenames when git-ignoring files (#4475)
- **PR Description**

Some characters in file names need to be escaped so that they work
correctly in .gitignore files. These include `#` and `!` (only at the
beginning of a filename), as well as `[`, `]`, and `*` anywhere in the
name.

Fixes #4075
Fixes #4445

- **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))
* [ ] If a new UserConfig entry was added, make sure it can be
hot-reloaded (see
[here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig))
* [ ] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
2025-04-13 18:31:23 +10:00
Stefan Haller
b0ab6529c1 Escape special characters when git-ignoring files 2025-04-13 18:25:24 +10:00
Stefan Haller
41f89d86f0 Add test that shows problems with git-ignoring files with special characters
For #, !, [, and ], the problem is that it doesn't ignore the file because the
special characters need to be quoted. For *, the problem is that it ignores too
much (it also hides the abc_def file because the * is treated as a glob).
2025-04-13 18:25:24 +10:00
Jesse Duffield
d70a405169
Fix crash with drag selecting and staging (#4480)
- **PR Description**

Fix a crash in the staging view when clicking below the end of the diff,
dragging upwards into the diff to select a range, and pressing space to
stage.

Fixes #4479.

- **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))
* [ ] If a new UserConfig entry was added, make sure it can be
hot-reloaded (see
[here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig))
* [ ] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
2025-04-13 18:25:09 +10:00
Stefan Haller
825e5c23c1 Fix crash when dragging from below the end of the diff upwards and then staging the range
We need to clamp the range start index of a selection range in the same way as
we clamp the selection index.
2025-04-11 10:14:46 +02:00
Stefan Haller
a3ae1c8e4d Refactor: extract function clampLineIdx
And reimplement using lo.Clamp instead of comparing manually.
2025-04-11 10:14:46 +02:00
Stefan Haller
61636d820c
Update translation files from Crowdin (#4473)
- **PR Description**

Update translation files from Crowdin. Some texts had to be deleted
because they are no longer accurate (e.g. the minimum git version
error), these need to be retranslated.
2025-04-10 11:42:41 +02:00
Stefan Haller
204f6c7edb Update translation files from crowdin 2025-04-10 11:40:55 +02:00
Stefan Haller
1106b67f20
fix: update vscode color to logo color (#4459)
The vscode folder color appears to be using the visual studio purple
color which is different from the vscode blue color. This updates it
using a color picker on the inner part of the logo.
2025-04-10 09:58:08 +02:00
Peter Cardenas
93899b82fa fix: update vscode color to logo color 2025-04-10 09:56:19 +02:00
Stefan Haller
12fa50a61c
Add a command to select all commits of the current branch (#4448)
- **PR Description**

This is useful for seeing the combined diff of all commits of a branch.

- **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))
* [ ] If a new UserConfig entry was added, make sure it can be
hot-reloaded (see
[here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig))
* [ ] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
2025-04-10 09:05:55 +02:00
Stefan Haller
80b5e21bd5 Add a command to select all commits of the current branch
This is useful for seeing the combined diff of all commits of a branch.
2025-04-10 09:02:09 +02:00
Stefan Haller
7bccf848af
Show "(hooks disabled)" in title bar of commit message editor (#4467)
- **PR Description**

It is shown either when committing with `w`, or when typing the skipHooks prefix
if there is one. This should hopefully make it clearer when the hooks are run
and when they are not.

```
╭─Commit summary───────────────────(hooks disabled)─ 7 ─────╮
│WIP foo                                                    │
╰───────────────────────────────────────────────────────────╯
```

- **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)
* [x] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [ ] If a new UserConfig entry was added, make sure it can be
hot-reloaded (see
[here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig))
* [ ] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
2025-04-10 08:59:55 +02:00
Stefan Haller
b3bffbec4a Show "hooks disabled" in title bar of commit message editor
It is shown either when committing with `w`, or when typing the skipHooks prefix
if there is one. This should hopefully make it clearer when the hooks are run
and when they are not.
2025-04-10 08:57:32 +02:00
Stefan Haller
2ee80d7150 Cleanup: don't render the commit length when typing in the description
Only the commit message has an effect on this value, the description doesn't.
2025-04-10 08:55:13 +02:00
Stefan Haller
a24189ba63
Prefill the commit subject with the skipHook prefix when pressing w (#4456)
We removed prefilling the skipHook prefix in b102646b20 (#4374) with
the intention of making it clearer that using the prefix in normal
commits and typing `w` to skip hooks are now two independent features.

It turns out that some people liked it with prefilling the prefix and
perceive it as a regression, so put it back in.

But only if we don't have a preserved message; this is an important use
case, when you try to make a normal commit, the hook fails, and then you
want to make the same commit with skipping the hook, but with the same
message that you already typed.
2025-04-10 08:54:46 +02:00
Stefan Haller
ced70903ec Prefill the commit subject with the skipHook prefix when pressing w
We removed prefilling the skipHook prefix in b102646b20 with the intention of
making it clearer that using the prefix in normal commits and typing `w` to skip
hooks are now two independent features.

It turns out that some people liked it with prefilling the prefix and perceive
it as a regression, so put it back in.

But only if we don't have a preserved message; this is an important use case,
when you try to make a normal commit, the hook fails, and then you want to make
the same commit with skipping the hook, but with the same message that you
already typed.
2025-04-10 08:53:11 +02:00
Stefan Haller
391654984b
Bump go-git, and get rid of github.com/imdario/mergo (#4460)
- **PR Description**

This updates our go-git fork to the newest version (based on 5.14.1),
and then updates the mergo dependency to use dario.cat/mergo instead of
github.com/imdario/mergo.
2025-04-09 11:26:30 +02:00
Stefan Haller
b78aa54439 Use dario.cat/mergo instead of github.com/imdario/mergo
It's the new canonical location as of 1.0.0, the old one is deprecated and stuck
on 0.3.something.
2025-04-09 11:23:55 +02:00
Stefan Haller
4cf49ff449 Bump go-git 2025-04-09 11:23:55 +02:00
Stefan Haller
da0105c16b
Add runCommand function to Go template syntax + add support for templates in git branchPrefix setting (#4438)
This makes it possible to use date and time in initial values like this:

```yaml
initialValue: 'ruudk/{{ runCommand "date +\"%Y/%-m\"" }}/'
```
![Screenshot 2025-04-02 at 19 41
40@2x](https://github.com/user-attachments/assets/7f5e79c6-c8c9-4047-83da-ee61240ded27)

I want to use this to configure my BranchPrefix like this:

```yaml
git:
  branchPrefix: 'ruudk/{{ runCommand "date +\"%Y/%-m\"" }}/'
```
![Screenshot 2025-04-02 at 19 43
06@2x](https://github.com/user-attachments/assets/c0c517d5-8bc3-4e83-944d-2bf591ac1521)
2025-04-09 11:11:07 +02:00
Ruud Kamphuis
12820481e6 Add runCommand function to Go template syntax
This makes it possible to use date and time in initial values like this:

```yaml
initialValue: 'ruudk/{{ runCommand "date +\"%Y/%-m\"" }}/'
```

I want to use this to configure my BranchPrefix like this:

```yaml
git:
  branchPrefix: 'ruudk/{{ runCommand "date +\"%Y/%-m\"" }}/'
```
2025-04-09 10:44:36 +02:00