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

2937 Commits

Author SHA1 Message Date
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
Stefan Haller
bf685cf832 Cleanup: improve test setup and check for the right error string
Use the assert package to check expectations; also, check for the exact error
message instead of just whether any error occurred.
2023-06-26 08:11:10 +02:00
Stefan Haller
8932d17393 Cleanup: remove unnecessary if statements
The assert package is already very good at displaying errors, including printing
a diff of expected and actual value, so there's no point in printing the same
information again ourselves.
2023-06-26 08:11:10 +02:00
Stefan Haller
1998d0724f Add a test for stopping at an "edit" command that conflicts
This test is almost identical to swap_in_rebase_with_conflict.go, except that it
sets the commit that will conflict to "edit".

This test is interesting because there's special code needed to determine
whether an "edit" command conflicted or not, i.e. whether to show the "confl"
entry. In this case we do. We have lots of other tests already that have "edit"
commands that don't conflict, so that's covered already.
2023-06-22 18:57:58 +02:00
Stefan Haller
3928d0ebda Insert fake todo entry for a conflicting commit that is being applied
When stopping in a rebase because of a conflict, it is nice to see the commit
that git is trying to apply. Create a fake todo entry labelled "conflict" for
this, and show the "<-- YOU ARE HERE ---" string for that one (in red) instead
of for the real current head.
2023-06-22 18:57:58 +02:00
Stefan Haller
d66ca7751c Add test for rewording a commit and failing with an error
The point of this test is to verify that the <--- YOU ARE HERE --- display is
correct when the last command in a rebase was "reword".
2023-06-22 18:57:43 +02:00
Stefan Haller
ba160cb5db Add test for a pick that fails and gets rescheduled
This test is interesting because it already behaves as desired: since git has
rescheduled the "pick" command, we do _not_ want to show a "conflict" entry in
this case, as we would see the same commit twice then.
2023-06-22 18:57:43 +02:00
Stefan Haller
3d76c734aa Add test for amending a commit, causing a conflict 2023-06-22 18:57:43 +02:00
Stefan Haller
cddf056f4d Extend test to expect what commits we want to be listed when there's a conflict 2023-06-22 18:57:43 +02:00
Stefan Haller
77c5d1761d Add nerdFontsVersion config 2023-06-15 21:47:52 +02:00
Stefan Haller
6ab5d7f69b Turn remoteIcons into a map
We don't actually use it to do map lookups; we still iterate over it in the same
way as before. However, using a map makes it easier to patch elements; see the
next commit.
2023-06-15 13:25:32 +02:00
Stefan Haller
1f42c8a387 Allow discarding changes only from local commits
We use CommitFilesController also for the files of commits that we show
elsewhere, e.g. for branch commits, tags, or stashes. It doesn't make sense to
discard changes from those (for stashes it might be possible to implement it
somehow, but that would be a new feature), so we disallow it unless we are in
the local commits panel.
2023-06-07 12:48:56 +02:00
Stefan Haller
5c55ce6555 Better prompt for discarding old file changes
Lazygit knows what kind of file change this is, so there doesn't have to be any
"if" in the prompt text.
2023-06-07 12:47:03 +02:00
Stefan Haller
1f801b91e4 Disallow discarding file changes while a directory is selected
Discarding changes to an entire directory doesn't quite work correctly in all
cases; for example, if the current commit added files to the directory (but the
directory existed before) then those files won't be removed.

It might be possible to fix the command so that these cases always work for
directories, but I don't think it's worth the effort (you can always use a
custom patch for that), so let's display an error for now.
2023-06-07 12:47:03 +02:00
Jesse Duffield
c92e687d3b Fix focus issue when opening recent-repos menu at launch
I don't know why we were setting the initial context to CurrentSideContext
and not just CurrentContext in the first place. If there is no current context
in either case it'll default to the files context. So the only issue is if
we anticipated that some random context would be focused and we didn't want to
activate that. But I can't think of any situation where that would happen.
2023-06-07 18:27:18 +10:00
Jesse Duffield
a694c458dd Support authors and tags in custom command suggestions preset 2023-06-07 10:18:01 +10:00
Enrico Borba
cbbb281011
kakoune binary name 2023-06-05 08:53:39 -04:00
Jesse Duffield
a9ae5063c2 Fix flakey test
Whenever we perform an action in a test, we should assert on the result before doing the next action.
This prevents issues where the test moves too fast for our code. It would be nice to not have to do this,
but for now that's the situation
2023-06-03 15:54:03 +10:00
Jesse Duffield
1932c2366b Appease linter 2023-06-03 15:54:03 +10:00
Jesse Duffield
dd34adb36c Support matchers on integers in integration tests 2023-06-03 15:32:23 +10:00
Jesse Duffield
e98935f83e
Merge pull request #2699 from jesseduffield/revert-hide-underscores 2023-06-01 22:30:56 +10:00
Jesse Duffield
4ff02bd3b7 Add integration test for commit highlighting on focus
A better refactor would be to allow matchers to assert against either a string or a slice of cells, so that I could have
the same ergonomics that I have elsewhere, but this is a start.
2023-06-01 22:20:30 +10:00
Jesse Duffield
5df27c61ed Apply correct styling to root commit in graph
The root commit is special in that it has no parents. So we need to add a pipe that's headed for a commit
that doesn't actually exist i.e. the mythical empty tree commit. We're using the actual hash of that
pseudo-commit, but it's not being read anywhere.
2023-06-01 22:20:30 +10:00
Jesse Duffield
c9136538b5 Refresh commits viewport on focus lost
We don't want the highlighted selection sticking around after the context loses focus.
2023-06-01 21:31:57 +10:00
Jesse Duffield
b250644ea8 Stop hiding underscores for VSCode
VSCode had an issue in their terminal where underscores were printed all over the place.
That has now been fixed.
See https://github.com/jesseduffield/lazygit/issues/2294 and https://github.com/xtermjs/xterm.js/issues/4238
2023-06-01 20:12:20 +10:00
Jesse Duffield
a4db44bc3d show commits against branches 2023-06-01 19:21:24 +10:00
Jesse Duffield
378c50cf30 Set defaults colours to 'default', not 'white'
'white' is great on dark themes, and terrible on light themes.
2023-06-01 18:59:04 +10:00
Jesse Duffield
860fd23b42
Merge pull request #2695 from jesseduffield/fix-time-ago-function 2023-06-01 18:53:55 +10:00
Stefan Haller
33e5f8f776
Merge pull request #2694 from stefanhaller/conflict-handling-menu
Show menu instead of prompt when there are conflicts in a rebase or merge
2023-06-01 10:52:11 +02:00
Stefan Haller
16dceb813b Show menu instead of prompt when there are conflicts in a rebase or merge
This solves the issue that previously you could too easily abort a rebase
accidentally by hitting escape.
2023-06-01 10:51:48 +02:00
Jesse Duffield
61f00e6dd4 update seconds ago function and add tests 2023-06-01 18:48:06 +10:00
Stefan Haller
31a2ea1f19 Add --all to "git fetch" command when not fetching a specific remote 2023-06-01 10:13:14 +02:00
Stefan Haller
697157f5d5 Add tests for Fetch 2023-05-31 15:54:20 +02:00
Stefan Haller
ee4b9d20b1 Extract a FetchCmdObj function so that we can test it
No change in behavior.
2023-05-31 15:54:20 +02:00
Stefan Haller
a2bdab2135 Remove unused fetch options RemoteName and BranchName
These were never used, since there are separate functions for fetching a remote
and for fast-forwarding a branch.
2023-05-31 15:54:20 +02:00
Jesse Duffield
614a30134c
Merge pull request #2688 from tzengyuxio/master 2023-05-31 09:36:12 +10:00
Jesse Duffield
cc0edd42bb
Merge pull request #2508 from Ryooooooga/remove-jesseduffield-yaml 2023-05-30 17:39:25 +10:00
Tzeng Yuxio
5d8af7bbd8
Add Traditional Chinese support 2023-05-30 12:58:11 +08:00
Jesse Duffield
1de876ed4d Support using command output directly in menuFromCommand custom command prompt
The menuFromCommand option is a little complicated, so I'm adding an easy way to just use the command output directly,
where each line becomes a suggestion, as-is.

Now that we support suggestions in the input prompt, there's less of a need for menuFromCommand, but it probably still
serves some purpose.

In future I want to support this filter/valueFormat/labelFormat thing for suggestions too. I would like to think a little more
about the interface though: is using a regex like we currently do really the simplest approach?
2023-05-29 22:52:16 +10:00
Jesse Duffield
036a1ea519 Support suggestions generated from command in custom commands
This changes the interface a bit but it was only added earlier today so I doubt anybody is dependent on it yet.

I'm also updating the docs.
2023-05-29 22:47:35 +10:00
Jesse Duffield
16fa22a36e Add suggestionsPreset to custom commands system 2023-05-29 14:24:49 +10:00
Jesse Duffield
0e0458f355 More compact and flexible date format
You can now configure both a time format and a short time format, where the short format kicks in
when the time is within the last day
2023-05-26 17:31:39 +10:00
Jesse Duffield
05bfa96936
Merge pull request #2672 from jesseduffield/sentence-case 2023-05-26 17:21:33 +10:00
Jesse Duffield
be6acf2fbe
Merge pull request #2670 from jesseduffield/better-list-context-trait 2023-05-26 15:28:32 +10:00
Jesse Duffield
9c384c5267 Clean up helix editor preset 2023-05-26 09:19:12 +10:00
Jesse Duffield
d772c9f1d4 Use sentence case everywhere
We have not been good at consistent casing so far. Now we use 'Sentence case' everywhere. EVERYWHERE.

Also Removing 'Lc' prefix from i18n field names: the 'Lc' stood for lowercase but now that everything
is in 'Sentence case' there's no need for the distinction.

I've got a couple lower case things I've kept: namely, things that show up in parentheses.
2023-05-25 23:52:19 +10:00
Jesse Duffield
e5534d9781
Merge pull request #2668 from dvic/add-helix-support 2023-05-25 19:59:14 +10:00
Jesse Duffield
e0ecc9e835 Allow global logging when developing
I'll be honest, for all I know logging should be global in general: it is
a pain to pass a logger to any struct that needs it. But smart people on the
internet tell me otherwise, and I do like the idea of not having any global
variables lying around.

Nonetheless, I often need to log things when locally debugging and that's a
different kind of logging than the kind you would include in the actual
released binary. For example if I want to log something from gocui, I would
rather not have gocui depend on lazygit's logging setup.
2023-05-25 18:31:32 +10:00
Jesse Duffield
add1de4138 Use boolean field to control whether viewport is refreshed on line focus
Go really doesn't like us doing anything inheritance-y: it does not support open recursion meaning
it's really hard to re-use code. As such, here we're falling back to conditional logic.

This fixes an issue where our ListContextTrait was calling FocusLine which was intended to be
overridden by ViewportListContextTrait, but the subclassed function wasn't being called. I'm
not actually sure how this went wrong given that it was working fine in the past, but at any rate,
the new code is easy to follow.
2023-05-25 17:09:18 +10:00
dvic
ed496deeca
Add helix editor preset 2023-05-24 23:08:26 +02:00
Jesse Duffield
1f8e838052
Merge pull request #2656 from mazharz/gitlab-merge-request-url
Update gitlab merge request URL to match new routing
2023-05-23 22:54:57 +10:00
Jesse Duffield
fb0931e1a1 Fix discard logic
Missed a spot a couple PR's ago. We had an integration test which caught this but which was skipped due
to index.lock file issues. The test was also broken for other reasons due to it not having been running
for a while, so I've fixed that up too.
2023-05-23 20:23:08 +10:00
Jesse Duffield
63dc07fded Construct arg vector manually rather than parse string
By constructing an arg vector manually, we no longer need to quote arguments

Mandate that args must be passed when building a command

Now you need to provide an args array when building a command.
There are a handful of places where we need to deal with a string,
such as with user-defined custom commands, and for those we now require
that at the callsite they use str.ToArgv to do that. I don't want
to provide a method out of the box for it because I want to discourage its
use.

For some reason we were invoking a command through a shell when amending a
commit, and I don't believe we needed to do that as there was nothing user-
supplied about the command. So I've switched to using a regular command out-
side the shell there
2023-05-23 19:49:19 +10:00
Jesse Duffield
1a4cf84b58
Merge pull request #2661 from jesseduffield/cache-binary-paths
Cache binary paths
2023-05-23 19:19:49 +10:00
Jesse Duffield
ad72a1f5a3 Cache binary paths
Turns out that with our secureexec package (which we only use on windows due to a windows security thing),
2023-05-23 19:15:33 +10:00
Mazhar Zandsalimi
59379b45da Update gitlab commit URL to match new routing 2023-05-22 07:39:47 +03:30
Mazhar Zandsalimi
2d4ca2b54f Update gitlab merge request URL to match new routing 2023-05-21 13:21:34 +03:30
Stefan Haller
ec5075104a
Merge pull request #2644 from stefanhaller/remove-empty=keep-option-when-rebasing
Don't keep commits that become empty during a rebase
2023-05-21 07:45:21 +02:00
Jesse Duffield
ec3a28df43 Right-align key labels in menu
I find this makes it look a little nicer
2023-05-21 12:09:43 +10:00
Jesse Duffield
3eed997161 Update cheatsheet
Now that we're using the angle-bracket syntax everywhere for consistency, we need to escape
the angle brackets in the markdown of the cheatsheets.
2023-05-21 11:31:29 +10:00
Jesse Duffield
e1fc90615d Apply strikethrough style to reserved keybindings in menus
If a given menu item has an associated keybinding of 'enter', hitting enter won't actually execute
that item unless your cursor is on it. This creates confusion, and so we're going to use a strikethrough
style to communicate that the keybinding is reserved for something else.
2023-05-21 11:31:29 +10:00
Jesse Duffield
460a166e16 Stop displaying navigation keybinding at bottom of screen
The reason for this is that now our labels for navigation keybindings are larger so they
take up more realestate. It's not the kind of thing a user needs to be told anyway,
anybody is going to try out hjkl and the arrow keys when a TUI opens up.

We could map from <up> to the single character up unicode rune but given you can rebind this stuff
I'd rather keep it simple
2023-05-21 11:01:15 +10:00
Jesse Duffield
2e66d87b94 Use same labels for keys that we use in the config
Previously we were displaying keys in a different format than we expected them in the config.
This was certain to cause confusion.
2023-05-21 10:59:16 +10:00
Jesse Duffield
820f7b9404 Support strikethrough text style 2023-05-21 10:46:13 +10:00
Stefan Haller
3cddd7cfa5 Don't keep commits that become empty during a rebase
The only exception is when moving a custom patch for an entire commit to an
earlier commit; in this case the source commit becomes empty, but we want to
keep it, mainly for consistency with moving the patch to a later commit, which
behaves the same.

In all other cases where we rebase, it's confusing when empty commits are kept;
the most common example is rebasing a branch onto master, where master already
contains some of the commits of our branch. In this case we simply want to drop
these.
2023-05-20 21:10:03 +02:00
Jesse Duffield
ed857d1e07 Show correct keybinding in tip 2023-05-20 23:36:34 +10:00
Jesse Duffield
ee11046d35 Refactor interface for ApplyPatch 2023-05-20 20:54:39 +10:00
Jesse Duffield
25f8b0337e Add convenience builder for git commands 2023-05-20 20:54:24 +10:00
Jesse Duffield
63ddc52a6b Increase test coverage 2023-05-20 16:55:15 +10:00
Stefan Haller
401610c0ef Remove the toast when toggling "ignore whitespace"
Now that we visualize the state, the toast is no longer needed.
2023-05-20 12:58:32 +10:00
Stefan Haller
64b2685c2d Visualize the "ignore whitespace" state in the subtitle of the diff view 2023-05-20 12:58:32 +10:00
Stefan Haller
7d4bfb6621 Don't toggle "ignore whitespace" in the staging and patch building panels
The option doesn't have any affect in these views, so we don't need to toggle it
here. But the problem was the HandleFocus call at the end: this would activate
the wrong view, so we need to avoid it here.

Show an error if the user tries to turn the option on, to let them know that it
doesn't work here.
2023-05-20 12:58:32 +10:00
Stefan Haller
a2778f01c6 Disregard the "ignore whitespace" option in the patch building panel
It's not possible to reliably stage things into a custom patch when "ignore
whitespace" is on, so always treat it as off here (like we do in the staging
panel).

It looks like this is a regression that was introduced in 8edad826ca.
2023-05-19 18:22:28 +02:00
Jesse Duffield
d161afe37f Support ignoring whitespace on stash 2023-05-19 17:49:22 +02:00
Jesse Duffield
681a9bf20d
Merge pull request #2612 from longlhh90/fix-commit-prefixes-with-empty-commit-message 2023-05-17 17:12:05 +10:00