1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-10 11:10:18 +02:00
Commit Graph

3111 Commits

Author SHA1 Message Date
Jesse Duffield
b5ff55e538 Show loader when switching worktrees 2023-07-30 18:35:23 +10:00
Jesse Duffield
81a9133261 Support older versions of git when fetching worktrees
Older versions of git don't support the -z flag in `git worktree list`.
So we're using newlines.

Also, we're not raising an error upon error because that triggers another refresh,
which gets us into an infinite loop
2023-07-30 18:35:23 +10:00
Jesse Duffield
ca6f9c4155 Fix tests
Going and fixing up some submodule tests which were broken by bad assumptions with worktree code
2023-07-30 18:35:23 +10:00
Jesse Duffield
7569180cac Fix tests
We now change directories to the repo on startup so we don't need to determine the test path in some special way
2023-07-30 18:35:23 +10:00
Jesse Duffield
eeec373728 Safer fetching of linked worktree paths 2023-07-30 18:35:23 +10:00
Jesse Duffield
0604e43813 Move worktrees tab to files window 2023-07-30 18:35:23 +10:00
Jesse Duffield
27ade502ee Change directory to worktree if given as an argument
Previously we used an env var for this and it's not clear to me how that worked but
with this PR current directory = worktree directory
2023-07-30 18:35:23 +10:00
Jesse Duffield
3a7468ecac Support opening worktree in editor 2023-07-30 18:35:23 +10:00
Jesse Duffield
7b05dacb98 Properly render worktrees in files panel 2023-07-30 18:35:22 +10:00
Jesse Duffield
b73efb2c22 Better logic for knowing which repo we're in 2023-07-30 18:35:22 +10:00
Jesse Duffield
a06a5cadee Only show worktree in status panel if not the main worktree and worktrees are supported 2023-07-30 18:35:22 +10:00
Jesse Duffield
3cd2d6fa5c Hide worktree functionality on old git versions 2023-07-30 18:35:22 +10:00
Jesse Duffield
ec839e9e96 Associate branches with worktrees even when mid-rebase 2023-07-30 18:35:22 +10:00
Jesse Duffield
6f2f9f6677 Assume that the base of a worktree can be checked out 2023-07-30 18:35:22 +10:00
Jesse Duffield
2082fdf84a i18n for worktrees 2023-07-30 18:35:22 +10:00
Jesse Duffield
894485190b Don't quit on error 2023-07-30 18:35:22 +10:00
Jesse Duffield
87b2455dbb Allow opening worktree in editor
This does the job but I think we need yet another editor command for opening a directory in a new window.
2023-07-30 18:35:22 +10:00
Jesse Duffield
2e68967e02 Show base ref suggestions when creating worktree 2023-07-30 18:35:22 +10:00
Jesse Duffield
71422a8549 Refresh work trees when discarding file changes
We do this because we may be deleting a worktree folder so we'll need to show that in the worktrees view
2023-07-30 18:35:22 +10:00
Jesse Duffield
9c69a5df69 Checkout worktree when creating from worktree view 2023-07-30 18:35:22 +10:00
Jesse Duffield
9b24995990 Use 'M' for months in branches panel 2023-07-30 18:35:22 +10:00
Jesse Duffield
142f06357f Fix filtering logic in worktrees view 2023-07-30 18:35:22 +10:00
Jesse Duffield
18ea68c23a Support creating worktrees from refs 2023-07-30 18:35:22 +10:00
Jesse Duffield
4b2622d93b Fix wording 2023-07-30 18:35:22 +10:00
Jesse Duffield
ae0193698e Log when directory is changed 2023-07-30 18:35:22 +10:00
Jesse Duffield
6b4a638415 Handle deleting branch attached to worktree 2023-07-30 18:35:22 +10:00
Jesse Duffield
4b3c9f5b35 Update wording 2023-07-30 18:35:22 +10:00
Jesse Duffield
6c69549ced Don't touch repo stack when switching worktrees
We shouldn't touch this cos we're doing a lateral move
2023-07-30 18:35:22 +10:00
Jesse Duffield
5868750aba Move status panel presentation logic into presentation package 2023-07-30 18:35:22 +10:00
Jesse Duffield
ab3052f642 Land in the same panel when switching to a worktree 2023-07-30 18:35:22 +10:00
Jesse Duffield
53f4ccb809 Move current worktree to top of list 2023-07-30 18:35:22 +10:00
Jesse Duffield
077ae99438 Prompt to switch to worktree when branch is checked out by other worktree 2023-07-30 18:35:22 +10:00
Jesse Duffield
fe8adf9eb8 Use git lingo 2023-07-30 18:35:22 +10:00
Jesse Duffield
c713d550c0 Improve name handling 2023-07-30 18:35:22 +10:00
Jesse Duffield
d19d89ea9d Use sentence case 2023-07-30 18:35:22 +10:00
Jesse Duffield
e8ec41fb0f Refactor 2023-07-30 18:35:22 +10:00
Jesse Duffield
7682ec029b Update worktree model 2023-07-30 18:35:22 +10:00
Jesse Duffield
03f726038e Alert when attempting to enter the current worktree 2023-07-30 18:35:21 +10:00
Jesse Duffield
796945aad0 Remove comment 2023-07-30 18:35:21 +10:00
Joel Baranick
db02c13bf6 Address PR comments 2023-07-30 18:35:21 +10:00
Joel Baranick
1ce9a87544 Basic support for adding a worktree 2023-07-30 18:35:21 +10:00
Joel Baranick
35e6e6347a Put all worktree i18n strings together
Use tabwriter to align worktree panel contents
2023-07-30 18:35:21 +10:00
Joel Baranick
54708233ac Improve worktree panel 2023-07-30 18:35:21 +10:00
Joel Baranick
c679fd1924 Style missing worktree as red and display better error when trying to switch to them
Use a broken link icon for missing worktrees
2023-07-30 18:35:21 +10:00
Joel Baranick
9a79154d05 Hide worktrees in the worktree panel if they point at a non-existing filesystem location.
Remove unneeded check when filtering out branches from non-current worktrees from the branch panel.
Add link icon for linked worktrees
2023-07-30 18:35:21 +10:00
Joel Baranick
60872c91e6 Update status to differentiate the main vs linked worktrees 2023-07-30 18:35:21 +10:00
Joel Baranick
afc4aedd4f Support for deleting a worktree 2023-07-30 18:35:21 +10:00
Joel Baranick
f8ba899b87 Initial addition of support for worktrees 2023-07-30 18:35:21 +10:00
Stefan Haller
6794149ec8 When bisecting, always mark the current commit as good/bad, not the selected
For marking as good or bad, the current commit is pretty much always the one you
want to mark, not the selected. It's different for skipping; sometimes you know
already that a certain commit doesn't compile, for example, so you might
navigate there and mark it as skipped. So in the case that the current commit is
not the selected one, we now offer two separate menu entries for skipping, one
for the current commit and one for the selected.
2023-07-29 14:44:00 +02:00
Stefan Haller
f30e09856c Add bisect menu entry that lets you choose bisect terms
This can be useful if you want to find the commit that fixed a bug (you'd use
"broken/fixed" instead of "good/bad" in this case), or if you want to find the
commit that brought a big performance improvement (use "slow/fast"). It's pretty
mind-bending to have to use "good/bad" in these cases, and swap their meanings
in your head.

Thankfully, lazygit already had support for using custom terms during the bisect
(for the case that a bisect was started on the command-line, I suppose), so all
that's needed is adding a way to specify them in lazygit.
2023-07-29 11:59:58 +02:00
Jesse Duffield
f17417219a
feat: add os.copyToClipboardCmd to allow for a custom command #1055 (#2784) 2023-07-29 19:35:52 +10:00
Red S
d7f84aed8a feat: add os.copyToClipboardCmd to allow for a custom command
Issue #1055

test: CopyPatchToClipboard (temporary commit for review)
2023-07-29 19:09:59 +10:00
Jesse Duffield
429225da80 Support random order of command execution in unit tests
Now that we run code concurrently in our loaders, we need to handle that in our tests.
We could enforce a deterministic ordering by mocking waitgroup or something like that,
but I think it's fine to let our tests handle some randomness given that prod itself
will have that randomness.

I've removed the patch test file because it was clunky, not providing much value, and
it would have been hard to refactor to the new pattern
2023-07-29 12:36:17 +10:00
Jesse Duffield
39b77c0fca Have staging refresh wait for files to refresh first 2023-07-29 10:20:15 +10:00
Jesse Duffield
63e5790410 Speed up refresh using concurrency and wait groups
Previously our synchronous refreshes took far longer because nothing
was happening concurrently. We now run refresh functions concurrently
and use a wait group to ensure they're all done before returning
2023-07-29 10:04:11 +10:00
Jesse Duffield
272e021c08 Refactor reflog commit loader
No functional changes
2023-07-29 10:04:11 +10:00
Jesse Duffield
862ebd25cb Speed up remote loader
We're:
* using concurrency with wait groups
* avoiding regex
* processing lines of input as they come rather than storing everything in one string
* avoiding an inner loop by creating a mapping of remote names to branches
2023-07-29 10:04:11 +10:00
Jesse Duffield
5d8a85f7e7 Use wait groups to speed up commit loading
The speedup is most noticeable on first load, when we haven't yet fetched out main branches.
I saw a speedup from 105ms to 60ms. On subsequent loads the gain is more modest;
54ms to 40ms
2023-07-29 10:04:11 +10:00
Jesse Duffield
5f30ccfbc3 Log duration of post-refresh-update call
Notably, the reflog view is taking ages here because it's got a
few thousand lines to write to the view.

In future we should only populate the view's viewport.
2023-07-29 09:39:22 +10:00
Jesse Duffield
71cab4fadc Log duration of commands
This will help us diagnose performance issues
2023-07-29 09:39:22 +10:00
Jesse Duffield
09ce430240 Log duration of refresh 2023-07-29 09:39:10 +10:00
Stefan Haller
67a7293e79 Show error when trying to open patch menu with an empty patch 2023-07-26 14:27:18 +02:00
hatredholder
75674d819c bring back yaml library fork 2023-07-26 12:50:39 +03:00
Jesse Duffield
c4e27bf96c Revert "Fix flakey pull_merge_conflict test"
This reverts commit 90613056ce, or the part that removed
a goroutine at least.

Reverting because this has caused an infinite wait for push/pull on windows.
We'll need to find out why that happens separately
2023-07-24 21:12:03 +10:00
Arnaud MASSERANN
4f807eeb19 Could not type special characters on non-english keyboards
On german/french/spanish keyboards, typing [ requires modifier
keys like AltGr, so the `mod==0` condition is wrong.

Fixes #2573

ch != 0 is useless because IsPrint is implemented this way:
	if uint32(r) <= MaxLatin1 {
		return properties[uint8(r)]&128 != 0
	}
with properties[0] set to 1 (so, bit 7 not set)
-> 0 is not printable.
2023-07-23 14:33:50 +02:00
Stefan Haller
c21633b1be Prompt for commit message when moving a custom patch to a new commit 2023-07-23 13:55:48 +02:00
Jesse Duffield
28474b08ee Fix crash caused by simultaneous read/write of scanner buffer 2023-07-23 13:17:37 +10:00
Jesse Duffield
7807b40322 Better tag creation UX
Previously we used a single-line prompt for a tag annotation. Now we're using the commit message
prompt.

I've had to update other uses of that prompt to allow the summary and description labels to
be passed in
2023-07-22 14:36:35 +10:00
Jesse Duffield
b46623ebef Use fuzzy search when filtering a view
This adds fuzzy filtering instead of exact match filtering, which is more forgiving of typos
and allows more efficiency.
2023-07-22 13:14:29 +10:00
Jesse Duffield
3cee37388c Keep track of authors across local commits and branch commits for suggestions
Previously, we would only show the authors based on local commits, but sometimes you want to set a commit author
to that of a commit on another branch. Now, so long as you've viewed the branch's commits, the author will appear
as a suggestion.
2023-07-22 10:47:04 +10:00
Andrew Savinykh
a7969aef2c Fix rendering to main view on windows 2023-07-22 09:14:05 +10:00
Jesse Duffield
87bf1dbc7f Only apply right-alignment on first column of keybindings menu
Previously we applied a right-align on the first column of _all_ menus, even though we really
only intended for it to be on the first column of the keybindings menu (that you get from pressing
'?')
2023-07-20 21:23:46 +10:00
Jesse Duffield
932e01b41a Add test for crashing on empty menu 2023-07-20 21:08:56 +10:00
Jesse Duffield
373f24c80f Fix crash on empty menu
When a menu is empty (e.g. due to filtering) we shouldn't crash on focus or selection
2023-07-20 21:05:52 +10:00
Jesse Duffield
866e0a618b Add integration test for accordion mode 2023-07-19 22:17:29 +10:00
Jesse Duffield
a5ee61c117 Properly fix accordion issue
The true issue was that we were focusing the line in the view before it gets resized in the layout function.
This meant if the view was squashed in accordion mode, the view wouldn't know how to set the cursor/origin to
focus the line.

Now we've got a queue of 'after layout' functions i.e. functions to call at the end of the layout function,
right before views are drawn.

The only caveat is that we can't have an infinite buffer so we're arbitrarily capping it at 1000 and dropping
functions if we exceed that limit. But that really should never happen.
2023-07-19 21:16:27 +10:00
Stefan Haller
39f3f150ed Fix crash when a background fetch prompts for credentials
This happens consistently for my when I close my MacBook's lid. It seems that
MacOS locks the user's keychain in this case, and since I have my keychain
provide the pass phrases for my ssh keys, fetching fails because it tries to
prompt me for a pass phrase.

This all worked correctly already, we have the FailOnCredentialRequest()
mechanism specifically for this situation, so all is great. The only problem was
that it was trying to pause the ongoing task while prompting the user for input;
but the task is nil for a background fetch (and should be).
2023-07-18 18:53:35 +02:00
Stefan Haller
6b769fb138 Fix populating the Commit.Tags field
We now store all tags in this field if there are several.
2023-07-15 13:07:02 +02:00
Stefan Haller
cc835a813e Extend commit_loader test to show how the Tags field is populated
It shows that right now, we take only the first tag if there are multiple.
Judging from how the code is written, I'm not sure this was intentional.
2023-07-15 13:07:02 +02:00
Stefan Haller
69575dd4f3 Fix potentially wrong help text in commit message panel
It said "Press tab to toggle focus", which is wrong for people who remapped
their togglePanel key binding to something else. Print the actual key binding
instead.
2023-07-15 13:03:13 +02:00
Jesse Duffield
78bbdca757 Add test for cmd obj cloning 2023-07-15 11:05:43 +10:00
Scott Callaway
9617737352 config: rely on .gitconfig for verbose commit messages
As discussed in https://github.com/jesseduffield/lazygit/pull/2599, it
makes more sense to have the user specify whether they want verbose
commits from their own git config, rather than lazygit config.

This means that we can remove all the code (including test coverage)
associated with the custom verbose flag, and lazygit will just inherit
the .gitconfig settings automatically.
2023-07-14 07:56:09 +02:00
Jesse Duffield
b61ca21a84 Allow checking for merge conflicts after running a custom command
We have a use-case to rebind 'm' to the merge action in the branches panel. There's three ways to handle this:
1) For all global keybindings, define a per-panel key that invokes it
2) Give a name to all controller actions and allow them to be invoked in custom commands
3) Allow checking for merge conflicts after running a custom command so that users can add their own 'git merge' custom command
that matches the in-built action

Option 1 is hairy, Option 2 though good for users introduces new backwards compatibility issues that I don't want to do
right now, and option 3 is trivially easy to implement so that's what I'm doing.

I've put this under an 'after' key so that we can add more things later. I'm imagining other things like being able to
move the cursor to a newly added item etc.

I considered always running this hook by default but I'd rather not: it's matching on the output text and I'd rather something
like that be explicitly opted-into to avoid cases where we erroneously believe that there are conflicts.
2023-07-13 18:40:34 +10:00
Jesse Duffield
d4eae73a68 Do not quote initial branch arg when creating repo
Also, we shouldn't pass the initial branch arg if it's empty.
2023-07-11 17:18:58 +10:00
Stefan Haller
62ab41c310 Fix pull rebase tests
It seems that older git versions would drop empty commits when rebasing. Since
this aspect is not relevant to what we're testing here, fix this by simply
avoiding empty commits in these tests.
2023-07-10 15:09:17 +02:00
Ryooooooga
85f7aa9d7b Fix conflict test
The test apply_in_reverse_with_conflict.go fails in git versions 2.30.8 and
earlier. Apparently the output "Applied patch to 'file2' cleanly" was only added
more recently. It's not essential that we check this output.
2023-07-10 15:09:17 +02:00
Stefan Haller
30ce7c8085 Replace uses of "git stash save" with "git stash push"
Save has been deprecated for a while, push is the recommended way to save a
stash. Push has been available since 2.13, so we can use it without problems.
2023-07-10 15:09:17 +02:00
Stefan Haller
1827380c69 Fix git stash calls for older git versions
Older git versions are pickier about parameter order: for "store", the sha
argument must come last, and for "save", the message must come last.
2023-07-10 15:09:17 +02:00
Stefan Haller
ea0baf58e6 Fix Shell.Stash() for older versions of git
Older versions need an explicit "push" subcommand for the -m option to be
recognized.
2023-07-10 15:09:17 +02:00
Stefan Haller
1d96ade0ba Remove StashWithMessage function
It's identical to Stash(), so use that.
2023-07-10 15:09:17 +02:00
Stefan Haller
82b3803164 Use -c init.defaultBranch=master to pass the desired main branch to git init
Older versions of git don't support the -b option yet. However, no version of
git complains about the -c option, even when the init.defaultBranch config is
not supported.
2023-07-10 15:09:17 +02:00
Stefan Haller
f4ada537d2 Remove mainBranch parameter from Shell.Init()
For older git versions we won't be able to support any other main branch than
"master", so hard-code that in Init.

This doesn't fix anything for older versions yet; see the next commit for that.
2023-07-10 15:09:17 +02:00
Jesse Duffield
9c0a151dfa Retry tests on CI
Now that we are running each test 6 times on CI, the risk of flakiness
is higher. I want to fix these tests for good but it'l take time, so
we're just retrying for now
2023-07-10 22:18:22 +10:00
Stefan Haller
cc316ab6de Fix interactive rebase with git 2.25.1 and earlier
The code in getHydratedRebasingCommits relied on the assumption that the
git-rebase-todo file contains full SHAs. This has only been true from 2.25.2 on,
before that it would contain abbreviated SHAs. Fix this by storing fullCommits
in a slice instead of a map, and using a linear search.
2023-07-10 13:42:35 +02:00
Jesse Duffield
16ed3c2377 Retry on index.lock error
I don't know why we're getting index.lock errors but they're impossile to stop
anyway given that other processes can be calling git commands. So we're retrying
a few times before re-raising. To do this we need to clone the command and the current
implementation for that is best-effort.

I do worry about the maintainability of that but we'll see how it goes.

Also, I thought you'd need to clone the task (if it exists) but now I think not;
as long as you don't call done twice on it you should be fine, and you shouldn't
be done'ing a task as part of running a command: that should happen higher up.
2023-07-10 19:13:18 +10:00
Jesse Duffield
d44d164a5a Ensure background refreshes don't bunch up 2023-07-10 17:30:44 +10:00
Jesse Duffield
90613056ce Fix flakey pull_merge_conflict test
It's not clear what was happening but it seemed like we sometimes weren't
fully writing to our stdout buffer (which is used for the error message)
even though we had returned from cmd.Wait().

Not sure what the cause was but removing an unnecessary goroutine fixed it.
2023-07-10 17:12:34 +10:00
Jesse Duffield
c05a1ae711 Fix flakey misc/initial_open test
I've simplifiied the code because it was too complex for the current requirements, and this fixed the misc/initial_open
test which was occasionally failing due to a race condition around busy tasks
2023-07-10 17:12:34 +10:00
Jesse Duffield
a0154dc525 Refactor 2023-07-10 17:12:21 +10:00
Jesse Duffield
6b9390409e Use an interface for tasks instead of a concrete struct
By using an interface for tasks we can use a fake implementation in tests with extra methods
2023-07-10 17:12:21 +10:00
Jesse Duffield
8964cedf27 Use mutex on cached git config
This fixes a race condition caused by a concurrent map read and write
2023-07-09 21:30:19 +10:00
Jesse Duffield
14ecc15e71 Use first class task objects instead of global counter
The global counter approach is easy to understand but it's brittle and depends on implicit behaviour that is not very discoverable.

With a global counter, if any goroutine accidentally decrements the counter twice, we'll think lazygit is idle when it's actually busy.
Likewise if a goroutine accidentally increments the counter twice we'll think lazygit is busy when it's actually idle.
With the new approach we have a map of tasks where each task can either be busy or not. We create a new task and add it to the map
when we spawn a worker goroutine (among other things) and we remove it once the task is done.

The task can also be paused and continued for situations where we switch back and forth between running a program and asking for user
input.

In order for this to work with `git push` (and other commands that require credentials) we need to obtain the task from gocui when
we create the worker goroutine, and then pass it along to the commands package to pause/continue the task as required. This is
MUCH more discoverable than the old approach which just decremented and incremented the global counter from within the commands package,
but it's at the cost of expanding some function signatures (arguably a good thing).

Likewise, whenever you want to call WithWaitingStatus or WithLoaderPanel the callback will now have access to the task for pausing/
continuing. We only need to actually make use of this functionality in a couple of places so it's a high price to pay, but I don't
know if I want to introduce a WithWaitingStatusTask and WithLoaderPanelTask function (open to suggestions).
2023-07-09 21:30:19 +10:00
Jesse Duffield
9e79ee5fe3 Add dev doc for busy/idle tracking 2023-07-09 20:57:18 +10:00
Jesse Duffield
fdee0e1497 Fix test
It's still skipped but it had an error
2023-07-09 20:57:18 +10:00
Jesse Duffield
bf7726d130 Fix race condition
We had some test flakiness involving the index.lock file which is fixed by this commit.
We shouldn't be accessing newTaskID without the mutex, although I'm surprised that this
actually fixes the issue. Surely we don't have tasks (which typically render to the main
view) which use index.lock?
2023-07-09 20:57:18 +10:00
Jesse Duffield
6282d55919 Only attempt integration tests once
I was able to get all integration tests passing 20 times in a row without any retries so I'm going to see
if we can rely on that in CI
2023-07-09 20:57:18 +10:00
Jesse Duffield
e588355f57 Add mutex for refreshing branches
We had a race condition due to refreshing branches in two different places, one which refreshed reflog commits
beforehand. The race condition meant that upon load we wouldn't see recency values (provided by the reflog commits)
against the branches
2023-07-09 20:57:18 +10:00
Jesse Duffield
c7a3b69eb9 Remove retry logic in integration tests
I want to see how we go removing all retry logic within a test. Lazygit should be trusted to tell us when it's no longer busy,
and if it that proves false we should fix the issue in the code rather than being lenient in the tests
2023-07-09 20:57:18 +10:00
Jesse Duffield
b19943af01 Wait for intro before doing any of our refresh functions
We were doing this already for fetching but not for refreshing files so I'm making it consistent.
2023-07-08 22:54:52 +10:00
Jesse Duffield
015a04fac6 Remove redundant waitgroup
Turns out we're just running our refresh functions one after the other which isn't ideal but we can fix that separately.
As it stands this wait group isn't doing anything.
2023-07-08 22:54:52 +10:00
Jesse Duffield
26ca41a40e Handle pending actions properly in git commands that require credentials
I don't know if this is a hack or not: we run a git command and increment the pending action
count to 1 but at some point the command requests a username or password, so we need to prompt
the user to enter that. At that point we don't want to say that there is a pending action,
so we decrement the action count before prompting the user and then re-increment it again afterward.

Given that we panic when the counter goes below zero, it's important that it's not zero
when we run the git command (should be impossible anyway).

I toyed with a different approach using channels and a long-running goroutine that
handles all commands that request credentials but it feels over-engineered compared to this
commit's approach.
2023-07-08 22:54:52 +10:00
Jesse Duffield
6c4e7ee972 Add busy count for integration tests
Integration tests need to be notified when Lazygit is idle so they can progress to the next assertion / user action.
2023-07-08 22:54:52 +10:00
Jesse Duffield
1a36cb9f3f
View filtering (#2680) 2023-07-03 12:57:11 +10:00
Jesse Duffield
5d982e1d70 Add mutex to filtered list to avoid concurrency issues 2023-07-03 12:54:14 +10:00
Jesse Duffield
b625eb5323 Differentiate between different filter modes
We can filter by path, by file status, and by text.
2023-07-03 12:54:14 +10:00
Jesse Duffield
8e46b8a275 Use searching, not filtering, in file tree views
There's more work to be done to support filtering for these views so we're sticking with searching for now
2023-07-03 12:54:14 +10:00
Jesse Duffield
cd989d8ebe Fix escape logic for remote branches
The remote branches controller was using its own escape method meaning it didn't go through the flow of cancelling
an active filter. It's now using the same approach as the sub-commits and commit-files contexts: defining a parent
context to return to upon hittin escape.
2023-07-03 12:54:14 +10:00
Jesse Duffield
261f30f49c Add integration tests for searching/filtering 2023-07-03 12:54:14 +10:00
Jesse Duffield
7d7399a89f Support case sensitive filtering 2023-07-03 12:54:14 +10:00
Jesse Duffield
9df634f13f Color view frame differently when searching/filtering
Given that we now persist search/filter states even after a side context loses focus, we need to make it really
clear to the user that the context is currently being searched/filtered
2023-07-03 12:54:14 +10:00
Jesse Duffield
3ca1292fb4 Show filter status similar to what we show with search 2023-07-03 12:54:14 +10:00
Jesse Duffield
13c1103815 Only cancel search if main or temporary context loses focus
This is a pickle: initially I wanted it so that a filter would cancel automatically if the current context lost focus.
But there are situations where you want to retain the focus, e.g. when a popup appears, or when you view the commits
of a branch. The issue is that when you view the commits of a branch, the branches context is removed from the context
stack. Even if this were not the case, you could imagine going branches -> sub-commits -> files -> sub-commits, where
in that case branches would definitely be off the stack upon navigating to the files context.

So because I'm too lazy to find a proper solution to this problem, I'm just making it so that filters in side contexts
are retained unless explicitly cancelled.

There's another edge case this commit handles which is that if I'm in the sub-commits context via the branches context
and start a search, then navigate to the reflog context and hit enter to get to the sub-commits context again, I need
to cancel the search before I switch. Likewise with the commit files context.
2023-07-03 12:54:14 +10:00
Jesse Duffield
b8bee4de51 Scroll to top when filtering and retain selection when cancelling filter 2023-07-03 12:54:14 +10:00
Jesse Duffield
d67b209e62 Move more logic into search helper 2023-07-03 12:54:14 +10:00
Jesse Duffield
bf5871cc4f Case insensitive string comparison 2023-07-03 12:54:13 +10:00
Jesse Duffield
13326344f0 Support filtering files 2023-07-03 12:54:13 +10:00
Jesse Duffield
84870d4503 Cancel filter/search when hitting escape 2023-07-03 12:54:13 +10:00
Jesse Duffield
a9e2c8129f Introduce filtered list view model
We're going to start supporting filtering of list views
2023-07-03 12:54:13 +10:00
Jesse Duffield
fd861826bc Add integration tests for discarding files 2023-07-03 12:54:13 +10:00
Jesse Duffield
c9a917b830 Print entire panic message
For some reason, the panic message was being truncated. So here we're printing it first, and then calling panic
2023-07-02 15:47:04 +10:00
Gustavo Krieger
9ae7710850 Use comment char config on interactive rebase
Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2023-07-02 02:07:32 -03:00
Gustavo Krieger
87fe30d50d Bump git-todo-parser 2023-07-02 02:07:32 -03:00
Gustavo Krieger
cff9850374 Add tests of interactive rebase with custom comment character 2023-07-02 02:07:32 -03:00
Stefan Haller
7cb54f4fee
Merge pull request #2748 from jesseduffield/always-show-branch-heads-in-diff
Always show branch heads in diff pane
2023-06-29 09:32:33 +02:00
Amirzhan Aliyev
62cc036254 fix: typo EnteRefName 2023-06-28 18:54:21 +06:00
Stefan Haller
a8aeadfdb7 Always show branch heads in diff pane
The first line of the diff pane would show branch heads (e.g.

  commit dd9100ccc8b69a8b14b21a84e34854b5acfb871a (mybranch, origin/mybranch)

only when a pager is used. The reason is that the default of the --decorate
option to git show is "auto", which means to show the decoration only when
output goes to a tty. Lazygit uses a pty only when a pager is used, so the
decoration wouldn't show when no pager is used.

Since the branch head annotation is useful and we always want to see it, force
it by explicitly passing --decorate.
2023-06-28 09:44:06 +02:00
Amirzhan Aliyev
5133113142 feat(i18n): add russian translation 2023-06-28 00:34:59 +06:00
Stefan Haller
ff8bc91a8e Use remote upstreams of main branches to determine merged status of commits
This solves three problems:

1. When the local main branch is behind its upstream, the merged status of
   commits of a feature branch sitting on origin/main was not correct. This can
   easily happen when you rebase a branch onto origin/main instead of main, and
   don't bother keeping local main up to date.
2. It works when you don't have the main branch locally at all. This could
   happen when you check out a colleague's feature branch that goes off of
   "develop", but you don't have "develop" locally yourself because you normally
   only work on "main".
3. It also works when you work on a main branch itself, e.g. by committing to it
   directly, or by merging a branch locally. These local commits on a main
   branch would previously be shown in green instead of red; this broke with
   910a61dc46.
2023-06-26 09:02:46 +02:00
Stefan Haller
2f6b7b9bc3 Rename the gui.skipUnstageLineWarning conf key to gui.skipDiscardChangeWarning 2023-06-26 08:19:58 +02:00
Stefan Haller
ee03a0be41 Rename "Delete change" menu entry to "Discard change" in staging panel
For consistency with the previous commit.

Note that this menu entry is used both for unstaged and for staged changes, and
for staged changes it is not quite accurate, as we are not discarding changes in
that case (just unstaging them). Not sure it's worth fixing this; it's still
better than "Delete", anyway.
2023-06-26 08:19:58 +02:00
Stefan Haller
51a558040d Fix the title and text (and variable names) of the Discard Changes prompt
The title was saying "Unstage lines", which was just wrong. The text said
"Delete lines", which can be seen as a bit misleading; we are only discarding
the changes to the selected lines, not deleting the lines themselves.

For consistency, rename the config variable skipUnstageLineWarning accordingly.
2023-06-26 08:15:35 +02:00
Stefan Haller
c4a2749a99 Avoid rewriting the file if nothing changed
This avoids changing the indentation or number of blank lines etc unnecessarily
if nothing has changed.
2023-06-26 08:11:10 +02:00
Stefan Haller
85f293af1a Add new function RenameYamlKey 2023-06-26 08:11:10 +02:00
Stefan Haller
9cbd7fe69e Extract a lookupKey function that will be useful in the next commit 2023-06-26 08:11:10 +02:00
Stefan Haller
4461dc68b7 Create missing path elements
This fixes a serious error: trying to change a value on gui.someOption would add
a someOption key at root if gui doesn't exist.
2023-06-26 08:11:10 +02:00
Stefan Haller
6acabba417 Return an error if some node in the path is not a dictionary 2023-06-26 08:11:10 +02:00
Stefan Haller
7fb86d6e9c Return an error if node to be updated is not a scalar 2023-06-26 08:11:10 +02:00
Stefan Haller
221433522d Return an error if document is not a dictionary 2023-06-26 08:11:10 +02:00
Stefan Haller
90084d115e Support updating values in empty documents 2023-06-26 08:11:10 +02:00
Stefan Haller
a14794bf5c Rename UpdateYaml to UpdateYamlValue
We are going to add other ways to update yaml documents in the future.
2023-06-26 08:11:10 +02:00