1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-25 12:24:47 +02:00

5773 Commits

Author SHA1 Message Date
Brandon
4e880e56c4 Add integration tests for checkout/new branch with autostash 2024-09-03 09:05:53 +02:00
Brandon
e8e39f5ce2 Offer autostash option when creating new branch 2024-09-03 09:05:53 +02:00
Brandon
370ab2d19c Simplify CheckoutRef 2024-09-03 09:05:53 +02:00
Stefan Haller
fa8cd47227
Don't allow opening a menu while the search or filter prompt is open (#3878)
- **PR Description**

This solves several problems that arise from opening a menu while the
prompt is open. We might try to solve these in a different way, e.g. by
dismissing the search prompt before opening a menu, but restricting what
you can do while the prompt is open seems like the more robust fix.

To achieve this, we
- call resetKeyBindings both when opening and when closing the
search/filter prompt
- change the keybindings to only contain the ones for the search prompt
when that context is active.

Fixes #3875.
2024-09-02 18:34:28 +02:00
Stefan Haller
9ec77bba91 Don't allow opening a menu while the search or filter prompt is open
This solves several problems that arise from opening a menu while the prompt is
open. We might try to solve these in a different way, e.g. by dismissing the
search prompt before opening a menu, but restricting what you can do while the
prompt is open seems like the more robust fix.

To achieve this, we
- call resetKeyBindings both when opening and when closing the search/filter
  prompt
- change the keybindings to only contain the ones for the search prompt when
  that context is active.
2024-09-02 18:31:30 +02:00
Stefan Haller
4ec9262ff6
Ask to auto-stage unstaged files when continuing a rebase after resolving conflicts (#3879)
- **PR Description**

When lazygit sees that all conflicts were resolved, it auto-stages all
previously conflicted files and asks to continue the rebase. (There is
[a PR](https://github.com/jesseduffield/lazygit/pull/3870) open to make
this optional.)

It is a common situation for this popup to be opened in the background,
while the user is still busy fixing build errors in their editor. In
this case, coming back to lazygit and confirming the continue prompt
would result in an error because not all files are staged.

Improve this by opening another popup in this case, asking to stage the
newly modified files too and continue.

See
https://github.com/jesseduffield/lazygit/issues/3111#issuecomment-1801751982
and the following discussion further down in that issue.
2024-09-02 18:27:08 +02:00
Stefan Haller
ba21d4e651 Ask to auto-stage unstaged files when continuing a rebase after resolving conflicts 2024-09-02 18:24:36 +02:00
Stefan Haller
3cffed9412
Make auto-staging resolved conflicts optional (#3870)
- **PR Description**

Add user config `git.autoStageResolvedConflicts` (default true). When
set to false, users need to stage their conflicted files manually after
resolving conflicts, and also continue a merge/rebase manually when all
conflicted files are resolved.

Fixes #3111.
2024-09-02 18:20:20 +02:00
Stefan Haller
90b8fd242d Add config git.autoStageResolvedConflicts 2024-09-02 18:12:47 +02:00
Stefan Haller
1191aca60f Actually look for conflict markers in GetHasInlineMergeConflicts
So far, lazygit has always auto-staged files as soon as the conflict markers
disappeared from them, which means that we could rely on any file that still had
a status of "UU" to still contain conflict markers.

We are going to make the auto-staging optional in the next commit, and in that
case the user will want to manually stage "UU" files; so we must now check
whether the file contains conflict markers, and disallow the staging in that
case.
2024-09-02 18:12:47 +02:00
Stefan Haller
2f01af49e8
Non-sticky range selection diff (#3869)
- **PR Description**

When selecting a range of commits, show the combined diff for them.

Along the way, fix a few minor issues with the current implementation of
diffing mode; see the individual commit messages for details.

Fixes #3862.

- **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
2024-08-31 08:16:32 +02:00
Stefan Haller
32fef9aadb Add a simple integration test for non-sticky range diff 2024-08-28 19:51:15 +02:00
Stefan Haller
717cb40f05 Cleanup: remove now unused ListControllerTrait from SwitchToDiffFilesController 2024-08-28 19:51:15 +02:00
Stefan Haller
ef7d1a8602 Use non-sticky range diff when entering commit files panel
We make the name of the GetSelectedRefRangeForDiffFiles very specific on purpose
to make it clear that this is only for switching to diff files, so the
implementations can make assumptions about that (unlike GetSelectedRef, which is
used for different purposes and needs to stay more generic).
2024-08-28 19:51:15 +02:00
Stefan Haller
a6656e307c Extract a method CommitFilesContext.ReInit
Right now it doesn't do very much yet, but it's still worth it even in this
state, I'd say. The function is going to become a bit longer in the next commit,
though.
2024-08-28 19:51:15 +02:00
Stefan Haller
442592a149 Show diff for range selection in commits and sub-commits panel
In other views that show lists of commits (reflog and stash) it doesn't make
sense to show a range diff of selected entries because they don't form a linear
sequence, so we keep the previous behavior of showing the diff for the free end
of the selection range in those view.

The same applies to the commits view if the selection range includes rebasing
todos; these can have an arbitrary order, and a range diff doesn't make sense
for those.
2024-08-28 19:35:23 +02:00
Stefan Haller
ac335907ae Add ShortRefName to Ref interface 2024-08-28 18:27:52 +02:00
Stefan Haller
b07ce19b9a Add --stat -p to diff args in diffing mode
This is consistent with what we do for showing single commits (with git show),
and I find it very useful.
2024-08-28 18:27:52 +02:00
Stefan Haller
079c5a9905 Add prefix to main view diff when in diffing mode
Hopefully this will help alleviate the problem that diffing mode is sticky, and
you often forget that it's still on.

Make it magenta like the mode text in the information view.
2024-08-28 18:27:52 +02:00
Stefan Haller
a2c4fad410 Bugfix: properly set title of subcommits panel when refreshing
This fixes two problems:
- Set the title ref to the commit description (like
  SwitchToDiffFilesController.enter does), rather than just the hash
- SetTitleRef only sets the title of the DynamicTitleBuilder, but doesn't set it
  on the view; this only happens in ContextMgr.Activate, so you'd have to switch
  to a different side panel and then back to see the new title.
2024-08-28 18:27:52 +02:00
Stefan Haller
567e898e22 Bugfix: don't allow dropping patches from a custom patch that was made in diffing mode
The three nested `if` statements may looks strange, and you might wonder why we
don't have single one with &&. The answer is that later in this branch we will
add an `else` block to the middle one.
2024-08-28 18:27:52 +02:00
Stefan Haller
14a29d6d6f Bugfix: more comprehensive check whether custom patch must be reset
We need to compare more than just the "To" ref. The NewPatchRequired function
existed already for this purpose, it just wasn't used.
2024-08-28 18:27:52 +02:00
Stefan Haller
8e2ed8c538 Extract helper function currentFromToReverseForPatchBuilding
In the next commit it will be reused for checking whether we need to reset the
patch; and extracting it makes it easier to extend it for non-sticky diff ranges
later in the branch.
2024-08-28 18:27:52 +02:00
Stefan Haller
6ad4ffea3b Cleanup: remove unnecessary viewFiles indirection
viewFiles is only called from enter; it doesn't make much sense to fill in a
SwitchToCommitFilesContextOpts struct to pass it to viewFiles for this one call.
Simply inline viewFiles into enter and get rid of all that.
2024-08-28 18:27:52 +02:00
Stefan Haller
770d51634c Cleanup: remove diffFilesContext field of SwitchToDiffFilesController
I found this indirection confusing when reading the code. It looks like
SwitchToDiffFilesController is instantiated with different such contexts, but
it's always Contexts.CommitFiles, so just use that directly.
2024-08-28 18:27:52 +02:00
Stefan Haller
c51e13941c Cleanup: remove unused translated text 2024-08-28 16:54:38 +02:00
Stefan Haller
05ae0800c3
Add codespell support (config, workflow to detect/not fix) and make it fix few typos (#3751)
More about codespell: https://github.com/codespell-project/codespell .

I personally introduced it to dozens if not hundreds of projects already
and so far only positive feedback.

CI workflow has 'permissions' set only to 'read' so also should be safe.
2024-08-27 18:05:45 +02:00
Yaroslav Halchenko
4bbfe7b3cc [DATALAD RUNCMD] run codespell throughout fixing typos automagically
=== Do not change lines below ===
{
 "chain": [],
 "cmd": "codespell -w",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^

Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>
2024-08-27 18:03:00 +02:00
Yaroslav Halchenko
00530477c9 [DATALAD RUNCMD] Do interactive fixing of some ambigous typos
=== Do not change lines below ===
{
 "chain": [],
 "cmd": "codespell -w -i 3 -C 2 ./pkg/commands/oscommands/cmd_obj_runner.go ./pkg/integration/tests/branch/rebase_and_drop.go",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^

Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>
2024-08-27 18:03:00 +02:00
Yaroslav Halchenko
90c1334535 Skip also for \nd
Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>
2024-08-27 18:03:00 +02:00
Yaroslav Halchenko
83ef031922 [DATALAD RUNCMD] Do interactive fixing of some ambigous typos
=== Do not change lines below ===
{
 "chain": [],
 "cmd": "codespell -w -i 3 -C 2",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^

Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>
2024-08-27 18:03:00 +02:00
Yaroslav Halchenko
820c2bc0fd custom skips for codespell
Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>
2024-08-27 18:03:00 +02:00
Yaroslav Halchenko
a484954d74 Add rudimentary codespell config
Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>
2024-08-27 18:03:00 +02:00
Yaroslav Halchenko
56be1a4950 Add github action to codespell master on push and PRs
Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>
2024-08-27 18:03:00 +02:00
Yaroslav Halchenko
1e8eb72b2f Do not git ignore .codespellrc
Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>
2024-08-27 18:03:00 +02:00
Stefan Haller
18935bf7f0
Fix linter warnings (#3854)
- **PR Description**

Fix some linter warnings that I keep getting locally because I'm running
a newer version of golangci-lint than the pinned version we use on CI.

Also, update the pinned version in CI to 1.60 so that we are in sync
again.

Finally, upgrade the golangci-lint-action version to the latest,
although I'm not sure what difference this makes. The linting step runs
faster now, maybe because of better caching -- I noticed that
previously, loading and saving the cache took a very long time, which
often made the lint step the slowest of all.
2024-08-27 13:12:40 +02:00
Stefan Haller
457c4c248d Upgrade golangci-lint-action to latest version 2024-08-27 10:33:06 +02:00
Stefan Haller
8c553dcde9 Upgrade golang-ci to 1.60 2024-08-27 10:33:06 +02:00
Stefan Haller
a709caf138 Remove error return value from functions that always return nil 2024-08-27 10:33:06 +02:00
Stefan Haller
8dea2dab88 Ignore return values of fmt.Scanln 2024-08-27 10:33:06 +02:00
Stefan Haller
63aa32c521 Remove "double" formatting 2024-08-27 10:33:06 +02:00
Stefan Haller
24841f22f1 Use print instead of printf when there are no arguments 2024-08-27 10:33:06 +02:00
Stefan Haller
d712c2f199 Use format arguments instead of concatenating strings
That's what they are for.
2024-08-27 10:33:06 +02:00
Stefan Haller
4525216d26
Fix cancelled autostash resulting in stuck inline status (#3860)
- **PR Description**

When switching branches, there is a "Checking out" inline status
displayed next to the branch (but only sometimes? I think if the action
completes too quickly there is no status). If it does get displayed and
the checkout results in an autostash confirmation prompt, pressing
escape to cancel the action will cancel the checkout and close the
prompt. However, the inline status will still be displayed next to the
branch and doesn't go away by itself. Performing a manual UI refresh
(`R`) fixes the state.

If the prompt was confirmed instead, then this issue would not happen.

Reproduction:
```bash
git init
echo -e "a\n\nb" > file
git add .
git commit -m "add file"
echo -e "a\n\nc" > file
git add .
git commit -m "edit last line"
git checkout -b dev HEAD~
echo -e "b\n\nb" > file
lazygit
```

Switch to the other branch in the branches panel and press escape on the
prompt. The "Checking out" inline status should be stuck.
2024-08-27 10:30:31 +02:00
Brandon
ae61da7485 Fix cancelled autostash resulting in stuck inline status 2024-08-27 10:28:22 +02:00
Stefan Haller
fb9f6153fc
Add missing closing quote in pager docs (#3864)
- **PR Description**

Add missing closing quote in pager docs.
2024-08-27 10:22:47 +02:00
Stefan Haller
a0c808842b Add missing closing quote 2024-08-27 10:16:53 +02:00
Stefan Haller
8a8490d97d
Underline hyperlinks only on mouse hover (#3856)
- **PR Description**

Followup to #3825: we decided there that we don't want to underline
links in delta diffs by default, but only on mouse hover. This PR does
that; it makes it possible to decide per view whether links should be
underlined always, or only on hover. We set this to only on hover for
the main views, so that links in diffs are not underlined (also affects
the status view though), but all other links we want to underline always
for better discoverability.
2024-08-24 17:49:10 +02:00
Stefan Haller
68c7f9840a Set main views to underline hyperlinks only on mouse hover
Note that this doesn't only affect the diff views, which are the ones where we
want this, but also the status view, where the plan was to keep them underlined
always for better discoverability. We could make this configurable dynamically
(by adding another flag to ViewUpdateOpts), but actually I think it's fine this
way.
2024-08-24 17:45:54 +02:00
Stefan Haller
8d37f48744 Bump gocui 2024-08-24 17:45:51 +02:00