1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-02 09:21:40 +02:00
Commit Graph

374 Commits

Author SHA1 Message Date
Stefan Haller
843e12286f Improve prompts when amending commits
This fixes two minor problems with the prompts:

1. When pressing shift-A in the local commits view, it would first prompt
   whether to stage all files, and then it would prompt whether to amend the
   commit at all. This doesn't make sense, it needs to be the other way round.

2. When pressing shift-A on the head commit in an interactive rebase, we would
   ask whether they want to amend the last commit, like when pressing shift-A in
   the files view. While this is technically correct, the fact that we're
   amending the head commit in this case is just an implementation detail, and
   from the user's point of view it's better to use the same prompt as we do for
   any other commit.

To fix these, we remove the confirmation panel from AmendHelper.AmendHead() and
instead add it at the two call sites, so that we have more control over this.
2023-09-01 18:55:16 +02:00
Stefan Haller
de4224bbe4 Fix escape not cancelling filter mode, but closing the menu instead
When filtering is on in a menu, pressing esc should only cancel the filter, but
not close the menu.
2023-08-30 22:37:13 +02:00
Stefan Haller
df38e954f4 Add integration test for the new divergence log 2023-08-29 08:16:40 +02:00
Stefan Haller
ea532b4729 Add DoesNotContainAnyOf matcher 2023-08-29 08:16:40 +02:00
Stefan Haller
3df01aaff0 Add a mechanism to insert non-model items into list contexts
Not used by anything yet.
2023-08-29 08:04:47 +02:00
Stefan Haller
98e6c119f5 Select same commit again after pressing "e" to edit a commit
When editing a commit, the index of the current commit can change; for example,
when merge commits are involved, or when working with stacked branches where
"update-ref" commands may be added above the selected commit.

Reselect the current commit after pressing "e"; this requires doing the refresh
blocking on the main thread. (Another option that I considered was to use a
SYNC refresh, and then select the new line with an OnUIThread inside the Then
function. This also works, but results in a very visible lag.)
2023-08-22 14:08:12 +02:00
Stefan Haller
93d19db158 Add assertion to show the problem 2023-08-22 14:06:29 +02:00
Stefan Haller
91ec42f3f8 Add integration test 2023-08-21 10:03:34 +02:00
Jesse Duffield
83d642b74f Add demo for diffing two commits 2023-08-12 17:24:05 +10:00
Jesse Duffield
b1bc437d1b Factor out common config setup functions in demo package 2023-08-12 16:52:40 +10:00
Jesse Duffield
8dd517870d Add commit graph demo 2023-08-12 16:16:03 +10:00
Jesse Duffield
f1753f36c8 Add rebase from marked base commit test
This also fixes a bug where after the rebase each commit in the commits view had a tick against it because we hadn't
refreshed the view since the base commit was no longer marked
2023-08-12 16:16:03 +10:00
Jesse Duffield
3ea81d4a6f Add undo demo 2023-08-12 16:15:50 +10:00
Federico
0df5cb1286
Allow deleting remote tags/branches from local tag/branch views (#2738) 2023-08-10 17:39:26 +10:00
Simon Whitaker
54776052a1 If OpenLink errors, show a dialog instead
If the command used by OSCommand.OpenLink fails, lazygit crashes. With this change, if the OpenLink command fails, lazygit just shows a dialog inviting the user to visit the relevant URL.

Fixes #2882
2023-08-09 13:12:40 +01:00
Simon Whitaker
ed1547e0cb Add a Click() primitive to the integration test library 2023-08-07 15:10:28 +01:00
Jesse Duffield
595e28d335 Support bare worktrees where worktree does not have its own .git file
This was on oversight on my part: I assumed that the --work-tree arg was
always intended for use with linked worktrees which have a .git file
pointing back to the repo.

I'm honestly confused now: seems like there are three kinds of worktrees:
* the main worktree of a non-bare repo
* a linked worktree (with its own gitdir in the repo's worktrees/ dir)
* a random folder which you specify as a worktree with the --work-tree arg

I'm pretty sure the --work-tree arg is only intended to be used with this
third kind or workree
2023-08-07 22:40:53 +10:00
Jesse Duffield
0551f29de9 Test bare repos with dotfile setup 2023-08-07 22:21:23 +10:00
Jesse Duffield
69ff621494 Use nerdfont version 3
Turns out I was on version 2 when recording these. I've switched
to v3 now.
2023-08-07 21:19:10 +10:00
Jesse Duffield
f6af4c29d4 Add custom patch demo 2023-08-04 09:15:07 +10:00
Jesse Duffield
996ad5bf26 Add worktree demo 2023-08-04 09:14:58 +10:00
Jesse Duffield
096628e366 Add custom command demo 2023-08-04 08:38:15 +10:00
Jesse Duffield
b432fb5efe Add undo/redo demo 2023-08-03 21:02:12 +10:00
Jesse Duffield
0152639ef0 Add demo for staging lines 2023-08-02 22:32:57 +10:00
Jesse Duffield
c43195efb6 Add demo for amending old commit 2023-08-02 22:32:51 +10:00
Jesse Duffield
17db918cba Add demo for filtering branches 2023-08-02 22:32:51 +10:00
Jesse Duffield
c92ed07082 Appease linter 2023-08-02 08:32:57 +10:00
Jesse Duffield
f43fd7af79 Wait in demo after setting caption
This looks nicer than waiting a second and then showing the caption as the action begins
2023-08-01 22:19:04 +10:00
Jesse Duffield
a200fccba9 Add explosion animation when nuking working tree
I've been thinking about this for a while: I think it looks really cool if nuking your working tree
actually results in a nuke animation.

So I've added an opt-out config for it
2023-08-01 22:16:04 +10:00
Jesse Duffield
1712ad08ae Start in fullscreen when passing a git arg
Often we just want to see the desired view in fullscreen so I'm making that the default
2023-08-01 22:10:59 +10:00
Jesse Duffield
b92c294059
Add automated demo recordings (#2853) 2023-07-31 22:43:36 +10:00
Jesse Duffield
9cc1d65280 Add demo test variant
We're piggybacking on our existing integration test framework to record  demos that we can include in our docs
2023-07-31 22:33:04 +10:00
Stefan Haller
3827479643 Show correct keybindings in force-push prompt 2023-07-31 11:38:52 +02:00
Stefan Haller
d41a195ee6 Allow force-tagging if tag exists 2023-07-31 11:38:52 +02:00
Stefan Haller
66de981e91 Add a "Mark commit as base commit for rebase" command
This allows to do the equivalent of "git rebase --onto <target> <base>", by
first marking the <base> commit with the new command, and then selecting the
target branch and invoking the usual rebase command there.
2023-07-31 08:41:41 +02:00
Stefan Haller
f5c9764dd2 Don't show branch heads in reflog subcommits
It's tricky to get this right for reflog commits wrt what's the current branch
for each one; so just disable it entirely here, it's probably not something
anybody needs here.
2023-07-31 08:34:01 +02:00
Stefan Haller
6dc25d796b Visualize local branch heads in commits panel
We want to mark all local branch heads with a "*" in the local commits panel, to
make it easier to see how branches are stacked onto each other. In order to not
confuse users with "*" markers that they don't understand, do this only for the
case where users actually use stacked branches; those users are likely not going
to be confused by the display. This means we want to filter out a few branch
heads that shouldn't get the marker: the current branch, any main branch, and
any old branch that has been merged to master already.
2023-07-31 08:34:01 +02:00
Stefan Haller
e9bbd816de Make bisect/basic.go test more concrete
- check out a non-main branch before we start
- add authors to expected commits so that we can see whether the commits show an
  asterisk
- explicitly check what the top line displays after bisecting has started

This shows that the detached head shows an asterisk, which we don't want. We'll
fix that in the next commit.
2023-07-31 08:34:01 +02:00
Stefan Haller
eb6f089a2a Add author short names to commits in test
This allow us to check not only whether a given commit has the branch head
marker, but also that other commits _don't_ have it, which is important.
2023-07-31 08:34:00 +02:00
Stefan Haller
cb240081a8 Improve updateRef test
This test not only tests the correct handling and display of the updateRef
command, but also the visualization of branch heads in the commits panel. Since
we are about to change the behavior here, extend the test so that a master
commit is added (we don't want this to be visualized as a branch head), and then
a stack of two non-main branches. At the end of this branch we only want to
visualize the head commit of the first.
2023-07-31 08:34:00 +02:00
Stefan Haller
9c57444adc Remove the old experimentalShowBranchHeads mechanism and config
We are going to replace it with a better one later in this branch.
2023-07-31 08:34:00 +02:00
Jesse Duffield
975d2bedb6 Remove secureexec package
From the go 1.19 release notes:

Command and LookPath no longer allow results from a PATH search to be found relative to the current directory. This removes a common source of security problems but may also break existing programs that depend on using, say, exec.Command("prog") to run a binary named prog (or, on Windows, prog.exe) in the current directory. See the os/exec package documentation for information about how best to update such programs.
2023-07-30 19:59:51 +10:00
Jesse Duffield
e33fe37a99 Standardise on using lo for slice functions
We've been sometimes using lo and sometimes using my slices package, and we need to pick one
for consistency. Lo is more extensive and better maintained so we're going with that.

My slices package was a superset of go's own slices package so in some places I've just used
the official one (the methods were just wrappers anyway).

I've also moved the remaining methods into the utils package.
2023-07-30 18:51:23 +10:00
Jesse Duffield
91909331b5 Fix flakey worktree tests
In the presentation layer, when showing branches, we'll show worktrees against branches if they're
associated. But there was a race condition: if the worktree model was refreshed after the branches model,
it wouldn't be used in the presentation layer when it came time to render the branches.

A better solution would be to have some way of signalling that a particular context needs to be refreshed
and after all the models are done being refreshed, we then refresh the contexts. This will prevent
double-renders
2023-07-30 18:35:36 +10:00
Jesse Duffield
a1fae41051 Fix bug where worktree view would take over window upon switching branches
When switching worktrees (which we can now do via the branch view) we re-layout the windows and their views.
We had the worktree view ahead of the file view based on the Flatten() method in context.go, because it used
to be associated with the branches panel.
2023-07-30 18:35:24 +10:00
Jesse Duffield
a77d24fdc6 Add section in integration readme about testing against old git versions 2023-07-30 18:35:24 +10:00
Jesse Duffield
06be88aef7 Use fields rather than methods on worktrees
I would prefer to use methods to keep things immutable but I'd rather be consistent with the other
models and update them all at once
2023-07-30 18:35:24 +10:00
Jesse Duffield
4c5b1574f1 Centralise logic for obtaining repo paths
There are quite a few paths you might want to get e.g. the repo's path, the worktree's path,
the repo's git dir path, the worktree's git dir path. I want these all obtained once and
then used when needed rather than having to have IO whenever we need them. This is not so
much about reducing time spent on IO as it is about not having to care about errors every time
we want a path.
2023-07-30 18:35:24 +10:00
Jesse Duffield
2b24c15938 Add test for opening lazygit in the worktree of a bare repo 2023-07-30 18:35:23 +10:00
Jesse Duffield
ae66f720f5 Update repo switch logic
We now always re-use the state of the repo if we're returning to it, and we always reset the windows to their default tabs.

We reset to default tabs because it's easy to implement. If people want to:
* have tab states be retained when switching
* have tab states specific to the current repo retained when switching back

Then we'll need to revisit this
2023-07-30 18:35:23 +10:00