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

2973 Commits

Author SHA1 Message Date
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
Lukas
0606b7a43b remove empty message check as message of commit can be empty 2023-05-17 17:07:50 +10:00
Stefan Haller
46b93bba0e Add config git.mainBranches
It defaults to {"master", "main"}, but can be set to whatever branch names
are used as base branches, e.g. {"master", "devel", "v1.0-hotfixes"}. It is
used for color-coding the shas in the commit list, i.e. to decide whether
commits are green or yellow.
2023-05-16 13:20:03 +02:00
Jesse Duffield
a82134f41c Fix race condition
Our refresh code may try to push a context. It does this in two places:
1) when all merge conflicts are resolved, we push a 'continue merge?' confirmation context
2) when all conflicts of a given file are resolved and we're in the merge conflicts context,
   we push the files context.

Sometimes we push the confirmation context and then push the files context over it, so the user
never sees the confirmation context.

This commit fixes the race condition by adding a check to ensure that we're still in the
merge conflicts panel before we try escaping from it
2023-05-16 21:01:38 +10:00
Jesse Duffield
00b03079d8 Don't deactivate context that you're about to activate 2023-05-16 21:01:38 +10:00
Jesse Duffield
9592686629 Compare contexts with keys
We don't want to compare contexts directly given they are interfaces and not
pointers to structs
2023-05-16 21:01:38 +10:00
Jesse Duffield
114ad52ff6 Rename CmdLog -> GuiLog
We want to log both actions and commands for the sake of integration tests
2023-05-16 21:01:38 +10:00
Stefan Haller
9514284f8e
Merge pull request #2608 from stefanhaller/allow-selected-line-outside-view
Allow the selected line of a list view to be outside the visible area
2023-05-13 12:29:17 +02:00
Stefan Haller
910a61dc46 Make "merged" take precedence over "unpushed"
Previously, when rebasing a branch onto a newer master, all commits from the
previous fork point up to its head were marked red (unpushed), including the
commits that are on master already. While this is technically correct from the
perspective of the current branch's upstream, it's not what most people expect,
intuitively; they want to see where the current branch starts, relative to
master. So all commits of master should be green, and then the commits of the
current branch in red.
2023-05-12 22:56:58 +02:00
Stefan Haller
e5dd4d3110 Allow the selected line of a list view to be outside the visible area
I don't see a reason why this restriction to have the selection be always
visible was necessary. Removing it has two benefits:

1. Scrolling a list view doesn't change the selection. A common scenario: you
   look at one of the commits of your current branch; you want to see the how
   many'th commit this is, but the beginning of the branch is scrolled off the
   bottom of the commits panel. You scroll down to find the beginning of your
   branch, but this changes the selection and shows a different commit now - not
   what you want.

2. It is possible to scroll a panel that is not the current one without changing
   the focus to it. That's how windows in other GUIs usually behave.
2023-05-11 13:23:58 +02:00
Stefan Haller
595c7ee73e Extend one of the filtering tests to start on a commit other than the first
Enabling the filter selects the first entry in the filtered commits view. It's
useful to have a test that checks this, as I almost broke it in the following
commit (it needs an added FocusLine call in the setFiltering function in
filtering_menu_action.go).
2023-05-11 13:23:58 +02:00
Jesse Duffield
007b406b14 remove duplicate method 2023-05-11 19:00:41 +10:00
Jesse Duffield
2b30085dba Merge branch 'master' into refactor-better-encapsulation 2023-05-11 19:00:01 +10:00
Jesse Duffield
e156e090cc add ability to update yaml path while preserving comments 2023-05-10 22:31:27 +10:00
Jesse Duffield
3cac14c76e add comment to encourage keeping code and docs in sync 2023-05-04 16:53:13 +10:00
Stefan Haller
d607b366cb Add own version for test move_to_earlier_commit for older git versions 2023-05-02 16:27:32 +02:00
Stefan Haller
c8f26aca68 Rename From to AtLeast 2023-05-02 16:27:32 +02:00
Ryooooooga
30656b5ac6 chore(git_commands): support old git version (git rebase --empty=keep) 2023-05-02 16:27:32 +02:00
Jesse Duffield
5dacbb6293 merge master into refactor-better-encapsulation 2023-05-02 19:05:42 +10:00
Stefan Haller
fba1a2b5ac Add config gui.experimentalShowBranchHeads
People find the new (*) display for branch heads in the commits list confusing,
so make it opt-in for now.
2023-05-02 18:58:54 +10:00
Jesse Duffield
c6c4346d48
Merge pull request #2551 from stefanhaller/fix-initial-context-activation 2023-05-01 21:22:43 +10:00
Jesse Duffield
ee9ae8f07f
Merge pull request #2552 from stefanhaller/support-stacked-branches 2023-05-01 21:07:19 +10:00
Jesse Duffield
af97bf484c Refresh staging panel when committing
We now refresh the staging panel when doing an unscoped refresh, so that if we commit from the staging panel we escape
back to the files panel if need be. But that causes flickering when doing an unscoped refresh from other contexts,
because the refreshStagingPanel function assumes that the staging panel has focus. So we're adding a guard at the top
of that function to early exit if we don't have focus.
2023-04-30 13:19:54 +10:00
Jesse Duffield
a57310df24 Retain commit message when cycling history
When cycling history, we want to make it so that upon returning to the original prompt, you get your text back.
Importantly, we don't want to use the existing preservedMessage field for that because that's only for preserving
a NEW commit message, and we don't want the history stuff of the commit reword flow to overwrite that.
2023-04-30 13:19:54 +10:00
Sean
9d68b287db Split commit message panel into commit summary and commit description panel
When we use the one panel for the entire commit message, its tricky to have a keybinding both for adding a newline and submitting.
By having two panels: one for the summary line and one for the description, we allow for 'enter' to submit the message when done from the summary panel,
and 'enter' to add a newline when done from the description panel. Alt-enter, for those who can use that key combo, also works for submitting the message
from the description panel. For those who can't use that key combo, and don't want to remap the keybinding, they can hit tab to go back to the summary panel
and then 'enter' to submit the message.

We have some awkwardness in that both contexts (i.e. panels) need to appear and disappear in tandem and we don't have a great way of handling that concept,
so we just push both contexts one after the other, and likewise remove both contexts when we escape.
2023-04-30 13:19:53 +10:00
Jesse Duffield
a5c72d056d ensure initial context is set when entering submodule 2023-04-30 13:19:53 +10:00
Jesse Duffield
8a86de85c8 remove log call because it clutters test output 2023-04-30 13:19:53 +10:00
Jesse Duffield
dd31f8ecea update cheatsheets 2023-04-30 13:19:53 +10:00
Jesse Duffield
5a7b2ab6d0 fix rendering of commit files view 2023-04-30 13:19:53 +10:00
Jesse Duffield
68a9d7fd77 appease linter 2023-04-30 13:19:53 +10:00
Jesse Duffield
19cbafcdfc remove unused file 2023-04-30 13:19:53 +10:00
Jesse Duffield
f2c85c5b19 move side window actions to controllers package 2023-04-30 13:19:53 +10:00
Jesse Duffield
0faa41e6f8 move toggle whitespace action to controllers package 2023-04-30 13:19:53 +10:00
Jesse Duffield
2e32e55957 update integration test for toggling whitespace 2023-04-30 13:19:53 +10:00
Jesse Duffield
037cd99138 move quit actions to controller 2023-04-30 13:19:53 +10:00
Jesse Duffield
d3e9bc2185 remove unused file 2023-04-30 13:19:53 +10:00
Jesse Duffield
ea4587a3b8 move some methods 2023-04-30 13:19:53 +10:00
Jesse Duffield
2da300f2fb move diffing menu action to controller 2023-04-30 13:19:53 +10:00
Jesse Duffield
7848958326 move filtering menu action to controller 2023-04-30 13:19:53 +10:00
Jesse Duffield
2cba98e3fe move another action into controller 2023-04-30 13:19:53 +10:00
Jesse Duffield
f8c9ce33c2 move more actions into controller 2023-04-30 13:19:53 +10:00
Jesse Duffield
71753770ad move custom patch options menu action to controllers package 2023-04-30 13:19:53 +10:00
Jesse Duffield
820b1e811d move custom command action into its own file 2023-04-30 13:19:53 +10:00
Jesse Duffield
4a33fede7b move window arrangement helper 2023-04-30 13:19:53 +10:00
Jesse Duffield
db12853bbe lots of changes 2023-04-30 13:19:53 +10:00
Jesse Duffield
711674f6cd standardise controller helper methods 2023-04-30 13:19:53 +10:00
Jesse Duffield
fc91ef6a59 standardise helper args 2023-04-30 13:19:53 +10:00
Jesse Duffield
43251e7275 split context common from helper common 2023-04-30 13:19:53 +10:00
Jesse Duffield
f081358943 move getDisplayStrings funcs into contexts 2023-04-30 13:19:53 +10:00
Jesse Duffield
0c6ab4b43e refactor cherry pick code to move state access out of helper 2023-04-30 13:19:53 +10:00
Jesse Duffield
1b2fb34ffd start moving getDisplayStrings funcs into contexts 2023-04-30 13:19:53 +10:00
Jesse Duffield
0e5a4c7a36 move getModel functions into contexts 2023-04-30 13:19:53 +10:00
Jesse Duffield
47b91f1ef5 move views into contexts 2023-04-30 13:19:53 +10:00
Jesse Duffield
e2db6a1732 remove context callback opts 2023-04-30 13:19:53 +10:00
Jesse Duffield
509e3efa70 lots more refactoring 2023-04-30 13:19:53 +10:00
Jesse Duffield
8edad826ca Begin refactoring gui
This begins a big refactor of moving more code out of the Gui struct into contexts, controllers, and helpers. We also move some code into structs in the
gui package purely for the sake of better encapsulation
2023-04-30 13:19:52 +10:00
Jesse Duffield
9adbef40de Refresh staging panel when committing
We now refresh the staging panel when doing an unscoped refresh, so that if we commit from the staging panel we escape
back to the files panel if need be. But that causes flickering when doing an unscoped refresh from other contexts,
because the refreshStagingPanel function assumes that the staging panel has focus. So we're adding a guard at the top
of that function to early exit if we don't have focus.
2023-04-30 12:17:34 +10:00
Jesse Duffield
0cd5257523 Retain commit message when cycling history
When cycling history, we want to make it so that upon returning to the original prompt, you get your text back.
Importantly, we don't want to use the existing preservedMessage field for that because that's only for preserving
a NEW commit message, and we don't want the history stuff of the commit reword flow to overwrite that.
2023-04-30 12:17:34 +10:00
Sean
49da7b482d Split commit message panel into commit summary and commit description panel
When we use the one panel for the entire commit message, its tricky to have a keybinding both for adding a newline and submitting.
By having two panels: one for the summary line and one for the description, we allow for 'enter' to submit the message when done from the summary panel,
and 'enter' to add a newline when done from the description panel. Alt-enter, for those who can use that key combo, also works for submitting the message
from the description panel. For those who can't use that key combo, and don't want to remap the keybinding, they can hit tab to go back to the summary panel
and then 'enter' to submit the message.

We have some awkwardness in that both contexts (i.e. panels) need to appear and disappear in tandem and we don't have a great way of handling that concept,
so we just push both contexts one after the other, and likewise remove both contexts when we escape.
2023-04-30 12:17:34 +10:00
Stefan Haller
d675117289 Fix activation of initial context
This broke with 40f6767cfc77; the symptom is that starting lazygit with a git
arg (e.g. "lazygit log") wouldn't activate the requested panel correctly. While
it would show in the expanded view, it didn't have a green frame, and keyboard
events would go to the files panel.
2023-04-29 07:37:44 +02:00
Jesse Duffield
e63858215e refactor moveFixupCommitDown 2023-04-29 07:28:33 +02:00
Stefan Haller
3fe4db9316 Make RebaseCommands.AmendTo more robust
This fixes two problems with the "amend commit with staged changes" command:

1. Amending to a fixup commit didn't work (this would create a commmit with the
   title "fixup! fixup! original title" and keep that at the top of the branch)
2. Unrelated fixup commits would be squashed too.

The added integration test verifies that both of these problems are fixed.
2023-04-29 07:28:33 +02:00
Jesse Duffield
185bbf0c75 Refactor to tighten interface to lazygit daemon 2023-04-29 07:28:33 +02:00
Stefan Haller
a8586ba57e Refactor: simplify PrepareInteractiveRebaseCommand API
Instead of passing a bunch of different options in
PrepareInteractiveRebaseCommandOpts, where it was unclear how they interact if
several are set, have only a single field "instruction" which can be set to one
of various different instructions.

The functionality of replacing the entire todo file with our own is no longer
available; it is only possible to prepend todos to the existing file.

Also, instead of using different env vars for the various rebase operations that
we want to tell the daemon to do, use a single one that contains a json-encoded
struct with all available instructions. This makes the protocol much clearer,
and makes it easier to extend in the future.
2023-04-29 07:28:33 +02:00
Stefan Haller
dad7a70bf8 Implement moving commits up/down in terms of daemon 2023-04-29 07:28:33 +02:00
Stefan Haller
3791f0b2fa Implement "move patch to selected commit" in terms of daemon 2023-04-29 07:28:33 +02:00
Stefan Haller
b8fbe9756e Implement squash, fixup, drop, and reword in terms of daemon 2023-04-29 07:28:33 +02:00
Stefan Haller
ab25600ccb Extract EditRebaseTodo into a function in utils.rebaseTodo
We want to reuse it from the daemon code in the next commit.
2023-04-29 07:28:33 +02:00
Stefan Haller
d50c58b4c6 Implement "edit commit" in terms of the new EditRebase function 2023-04-29 07:28:33 +02:00
Stefan Haller
5645a662de Use --rebase-merges for interactive rebase
At the moment it doesn't make a big difference, because the vast majority of
callers create a list of todos themselves to completely replace what git came up
with. We're changing this in the following commits though, and then it's helpful
to preserve merges.
2023-04-29 07:28:33 +02:00
Stefan Haller
a41218551d Put gitCommon.version back in deps_test.go
This was reverted in 3546ab8f21, but shouldn't have.
2023-04-29 07:28:33 +02:00
Jesse Duffield
aec46942a8 enforce lowercase filenames 2023-04-29 13:05:05 +10:00
Jesse Duffield
aa70723e3a
Merge pull request #2558 from stefanhaller/allow-resetting-author-during-rebase 2023-04-29 12:44:14 +10:00
Jesse Duffield
7db54a948a
Merge pull request #2548 from AKARSHITJOSHI/fix/tagPush 2023-04-29 12:43:55 +10:00
J. B. Rainsberger
6c010a788c
Add an editor preset for kakoune (kakoune.org). 2023-04-27 13:41:54 -03:00
Jesse Duffield
79dc1d9052
Merge pull request #2557 from noahziheng/feature/add-gitea-pr 2023-04-24 13:42:05 +10:00
Noah Gao
bf3dd79b7a feat: add gitea to hosting service 2023-04-18 16:16:09 +00:00
Stefan Haller
21072226d2 Don't allow resetting non-HEAD commits (including rebase todos) during rebase 2023-04-18 17:34:07 +02:00
Stefan Haller
b09000194a Allow resetting author of HEAD commit during rebase 2023-04-18 17:33:33 +02:00
Ryooooooga
3546ab8f21
Revert "feat: support for push --force-if-includes"
This reverts commit e00f248cf7.
2023-04-17 19:37:33 +09:00
Personal
9a13447b97 Change push tag command
Signed-off-by: AKARSHITJOSHI <akarshitjoshi@gmail.com>
2023-04-16 10:37:11 +05:30
AzraelSec
08a445eb9d test: check focus on commits after performing an advanced rebase 2023-04-15 11:01:55 +02:00
AzraelSec
28501fbf77 chore: add focus on local commits after interactively rebase 2023-04-15 10:42:36 +02:00
Jesse Duffield
8f1f712841 use lowercase text for menu items (as we're still yet to standardise on 'Sentence case') 2023-04-15 17:29:31 +10:00
AzraelSec
b82b6a2992 test: add integration test to verify the interactive rebase correctly work 2023-04-15 17:26:08 +10:00
AzraelSec
ddcd6be245 refactor: introduce a struct to pack the
`PrepareInteractiveRebaseCommand` function
2023-04-15 17:26:08 +10:00
Jesse Duffield
711be78811 extract out function 2023-04-15 17:26:08 +10:00
AzraelSec
3422b1e218 test: update the UI to follow the new rebase type selection instead of confirm the previous popup 2023-04-15 17:26:08 +10:00
AzraelSec
a3fdf91714 feat: allow to perform a rebase with breaking before the first commit 2023-04-15 17:26:08 +10:00
AzraelSec
368f9c8cb3 feat: let interactive rebase prepend commands to the default todo file 2023-04-15 17:26:08 +10:00
Stefan Haller
d675eb6507 Don't allow changing the type of certain rebase todos
We already show "merge" todo entries when starting an interactive rebase with
--rebase-merges outside of lazygit. Changing the type of a merge entry to "pick"
or "edit" doesn't make sense and shouldn't be allowed. Earlier in this branch we
have started to show "update-ref" entries, these can't be changed either (they
can be moved, though).

You might argue that it should be possible to change them to "drop", but in the
case of "update-ref" this doesn't make sense either, because "drop" needs a Sha
and we don't have one here. Also, you would then be able to later change it back
to "pick", so we would have to remember that this isn't allowed for this
particular drop entry; that's messy, so just disallow all editing.
2023-04-15 08:36:03 +02:00
Stefan Haller
dc4e88f8a4 Make moving todo commits more robust 2023-04-15 08:36:03 +02:00
Stefan Haller
120dd1530a Make EditRebaseTodo more robust
It used to work on the assumption that rebasing commits in lazygit's model
correspond one-to-one to lines in the git-rebase-todo file, which isn't
necessarily true (e.g. when users use "git rebase --edit-todo" at the custom
command prompt and add a "break" between lines).
2023-04-15 08:36:03 +02:00
Stefan Haller
860a8d102b Add integration test for dropping a todo commit when there's an update-ref
The test shows how we are accidentally dropping the wrong commit in this case.
We'll fix that in the next commit.
2023-04-15 08:36:03 +02:00
Stefan Haller
a304fed68c Add GitVersion field to NewIntegrationTestArgs
It can be used to specify which git versions a given test should or should not run on.
2023-04-15 08:36:03 +02:00
Stefan Haller
227b0b781c Show update-ref commands in rebase todo list
This is useful when working with stacked branches, because you can now move
"pick" entries across an update-ref command and you can tell exactly which
branch the commit will end up in.

It's also useful to spot situations where the --update-refs option didn't work
as desired. For example, if you duplicate a branch and want to rebase only one
of the branches but not the other (maybe for testing); if you have
rebase.updateRefs=true in your git config, then rebasing one branch will move
the other branch along. To solve this we'll have to introduce a way to delete
the update-ref entry (maybe by hitting backspace?); this is out of scope for
this PR, so for now users will have to type "git rebase --edit-todo" into the
custom command prompt to sort this out.

We will also have to prevent users from trying to turn update-ref commands into
other commands like "pick" or "drop"; we'll do this later in this branch.
2023-04-15 08:36:03 +02:00
Stefan Haller
740474c10c Visualize branch heads in commits panel
Useful when working with stacked branches.
2023-04-15 08:36:03 +02:00
Stefan Haller
a0d179b6dc Make getHydratedRebasingCommits more robust
So far the algorithm worked on the assumption that the output of the "git show"
command corresponds one-to-one to the lines of the rebase-todo file. This
assumption doesn't hold once we start to include todo lines that don't have a
sha (like update-ref), or when the todo file contains multiple entries for the
same sha. This should never happen normally, but it can if users manually edit
the todo file and duplicate a line.
2023-04-15 08:36:03 +02:00
Stefan Haller
c53c5e47ef Store commit.Action as an enum instead of a string
The main reason for doing this (besides the reasons given for Status in the
previous commit) is that it allows us to easily convert from TodoCommand to
Action and back. This will be needed later in the branch. Fortunately,
TodoCommand is one-based, so this allows us to add an ActionNone constant with
the value 0.
2023-04-15 08:36:03 +02:00
Stefan Haller
188773511e Store commit.Status as an enum instead of a string
This is unrelated to the changes in this PR, but since we are doing the same
thing for the commit.Action field in the next commit, it makes sense to do it
for Status too for consistency. Modelling this as an enum feels more natural
than modelling it as a string, since there's a finite set of possible values.
And it saves a little bit of memory (not very much, since none of the strings
were heap-allocated, but still).
2023-04-15 08:36:03 +02:00
Jesse Duffield
7f5465a27b fix flaky tests 2023-04-14 21:01:45 +10:00
Stefan Haller
6a340ec840 Reorder tests 2023-04-13 19:17:08 +02:00
Stefan Haller
3535cd0f94 Rename test files to match test names 2023-04-13 19:17:08 +02:00
Jesse Duffield
82c54ed3d2
Merge pull request #2544 from scallaway/git-diff-detect-renames 2023-04-13 21:47:59 +10:00
Jesse Duffield
bd62b519de
Merge pull request #2496 from jesseduffield/feature/prevent-history-custom-command 2023-04-13 21:25:35 +10:00
Jesse Duffield
04e0a9bb45
Merge pull request #2523 from stefanhaller/editor-config 2023-04-13 21:22:17 +10:00
Luka Markušić
2b4ac986a2 Don't add custom command to history if it starts with space
Add tests for custom command with leading space
2023-04-13 21:20:46 +10:00
Stefan Haller
046b0d9daa Show warning about deprecated edit configs
We print this to the terminal after lazygit quits rather than showing it in a
panel at startup, so as to not annoy people too much. Hopefully it will still be
prominent enough this way.
2023-04-13 13:14:00 +02:00
Stefan Haller
e4e16fa38e Change OpenCommand to Open and OpenLinkCommand to OpenLink
We do this for consistency with the edit settings. The old names are kept as a
fallback for now.
2023-04-13 13:14:00 +02:00
Stefan Haller
b7e029adc7 Don't set platform defaults on OSConfig struct immediately
Instead, query the platform defaults only if the config is empty. This will be
necessary later to distinguish an empty config from a default config, so that we
can give deprecation warnings.
2023-04-13 13:14:00 +02:00
Stefan Haller
08d679c3a8 Remove line number support for "open" command
The "open" command is supposed to behave in the same way as double-clicking a
file in the Finder/Explorer. The concept of jumping to a specific line in the
file doesn't make sense for this; use "edit" instead.
2023-04-13 13:14:00 +02:00
Stefan Haller
2947b56134 Add support for falling back to legacy edit config 2023-04-13 13:14:00 +02:00
Stefan Haller
659d668e16 Implement edit presets 2023-04-13 13:14:00 +02:00
Stefan Haller
7bbcec965b Cleanup: fix copy/paste error in comment 2023-04-13 13:14:00 +02:00
Stefan Haller
24de156592 Fix windows tests
Now that the tests run again, it turns out that they actually fail, so fix them.
2023-04-13 13:14:00 +02:00
Stefan Haller
8d3cce4a49 Rename test files so that test discovery works again
These files were renamed from os_windows_test.go to os_test_windows.go (etc.) in
95b2e9540a. Since then, the tests have no longer run, since go only looks for
tests in files ending with "test.go".

It isn't important that the file name ends with "_windows.go", since there are
already build constrains in the files themselves.
2023-04-13 13:14:00 +02:00
Scott Callaway
6ffe98abac
feat: remove --no-renames flag from main panel diffs (to show renamed files) 2023-04-13 10:57:38 +01:00
Scott Callaway
046cb942c2
fix: organise commit test file
Pulled this out into a separate commit since it was unrelated to the
feature coming behind it.

This just cleans up the `commit_test.go` file slightly (for the method
that I was working on) so that the tests are built in a way that is
slightly more readable - testing each configuration option individually
without combining any of them.
2023-04-12 12:31:06 +01:00
Andrew
298dae23e8 fix: generalize parsing of ssh git urls 2023-04-03 12:10:30 +10:00
Jesse Duffield
a02b54e1b7
Merge pull request #2497 from stefanhaller/fix-initial-scroll-bar-size 2023-04-02 16:38:07 +10:00
Jesse Duffield
0af4e5a843 prevent unnecessary re-renders of view 2023-04-02 15:44:05 +10:00
Stefan Haller
d508badd62 Better error message when trying to amend a commit other than head during rebase 2023-04-01 08:16:15 +02:00
Luka Markušić
e7d0116312 Allow amending the head commit during interactive rebase 2023-04-01 08:16:15 +02:00
Stefan Haller
85fdb700ba Extract amendHead function into new AmendHelper 2023-04-01 08:16:15 +02:00
Stefan Haller
7513d77567 Add integration test for amending from the files panel 2023-04-01 08:16:15 +02:00
Stefan Haller
c757063264 Better error message when trying to edit or move a non-todo commit during rebase
Previously we would have tried to do the rebase, resulting in a long and
somewhat cryptic error message from git; now we check ourselves and show a less
intimidating message.
2023-04-01 08:16:15 +02:00
Stefan Haller
b24955063c Allow rewording the head commit during interactive rebase 2023-04-01 08:16:15 +02:00
Stefan Haller
c6930e0538 Cleanup: use commit.isTODO() consistently
It seems cleaner than checking the Status for "rebasing".
2023-04-01 08:16:15 +02:00
Jesse Duffield
213ae8dd07 fix reflog text colour by defaulting every view to the same foreground colour 2023-03-26 15:24:09 +11:00
Jesse Duffield
4780953cef
Merge pull request #2377 from shinhs0506/clear-staging-after-commit 2023-03-24 19:13:00 +11:00
Jesse Duffield
8121a0cc74 remove old integration test recording code 2023-03-24 18:42:11 +11:00
Stefan Haller
4adca84d68 Make sure scrollbars have the right size initially
We refresh the view after reading just enough to fill it, so that we see the
initial content as quickly as possible, but then we continue reading enough
lines so that we can tell how long the scrollbar needs to be, and then we
refresh again. This can result in slight flicker of the scrollbar when it is
first drawn with a bigger size and then jumps to a smaller size; however, that's
a good tradeoff for a solution that provides both good speed and accuracy.
2023-03-21 18:26:18 +01:00
Stefan Haller
b7c61aa883 Push initial context instead of just putting it in the context array
This makes sure activateContext gets called on it.
2023-03-20 20:14:13 +11:00
Stefan Haller
40f6767cfc Avoid deactivating and activating when pushing the current context again
When calling PushContext, do nothing if the context to be pushed is already on
top of the stack. Avoids flicker in certain situations.
2023-03-20 20:14:13 +11:00
John Shin
776d8f4d2e refresh the staging panel on successful commit
apply formatting
2023-03-20 20:13:59 +11:00
Jesse Duffield
4b67a45a16
Merge pull request #2515 from stefanhaller/fix-deprecated-rand-seed 2023-03-20 20:12:25 +11:00
Jesse Duffield
a82d952f48
Merge pull request #2495 from jesseduffield/feature/remove-altreturn 2023-03-20 20:11:35 +11:00
Stefan Haller
549ce09f71 Fix deprecated rand.Seed 2023-03-19 10:00:19 +01:00
Jesse Duffield
60f902f026 rename patch manager to patch builder 2023-03-19 16:35:57 +11:00
Jesse Duffield
7ce3165afa specify view when assertion on line count fails 2023-03-19 16:30:39 +11:00
Jesse Duffield
73c7dc9c5d refactor patch code 2023-03-19 16:30:39 +11:00
Jesse Duffield
e6274af015
appease golangci-lint (#2512) 2023-03-19 11:20:29 +11:00
Luka Markušić
8dbd7d44ff
Fix checking for credentials performance (#2452)
Co-authored-by: Jesse Duffield <jessedduffield@gmail.com>
2023-03-19 11:08:54 +11:00
Stefan Haller
4b4dccfd7d
Fix "move patch into new commit" for partial hunk (#2507) 2023-03-18 18:17:47 +11:00
Jens Kutilek
5c8bc790ff
Make arrows consistent (#2501) 2023-03-18 11:32:44 +11:00
yk-kd
b5d612e6d6
Add border config (#2344)
Co-authored-by: yk-kd <yosuke.komada@gmail.com>
2023-03-18 11:23:31 +11:00
Ryooooooga
33f332e28d
build: remove github.com/jesseduffield/yaml package 2023-03-17 23:19:11 +09:00
Ryooooooga
55fb3ef4e6
fix(commit_loader): fix log command 2023-03-16 20:13:23 +09:00
Luka Markušić
f314cb3763 Remove alternative confirmation and return keymappings 2023-03-09 10:32:00 +01:00
Jesse Duffield
0bda93d4c3 Add more unit tests 2023-03-08 09:19:23 +11:00
Stefan Haller
4bd1322941 Rename WillBeAppliedReverse to Reverse
This is the only "reverse"-related option that is left, so use a less clumsy
name for it.
2023-03-07 13:40:07 +01:00
Stefan Haller
45cf993982 Remove the PatchOptions.Reverse option
All callers pass false now (except for the tests, which we simply remove), so we
don't need the option any more.
2023-03-07 13:39:45 +01:00
Stefan Haller
e4659145e8 Use WillBeAppliedReverse (and git apply --reverse) in the staging panel too
It's simpler to have only one way of reversing a patch.
2023-03-07 13:38:19 +01:00
Stefan Haller
bf6e9a1bd3 Reenable failing test 2023-03-07 09:49:34 +01:00
Stefan Haller
a68cd6af9c Concatenate patches to apply them all at once
This fixes the problem that patching would stop at the first file that has a
conflict. We always want to patch all files.

Also, it's faster for large patches, and the code is a little bit simpler too.
2023-03-07 09:49:34 +01:00
Stefan Haller
4ca012dbfb Add test for reverse-applying a patch that conflicts
The patch contains changes to two files; the first one conflicts, the second
doesn't. Note how it only applies changes to the first file at this point in the
branch; we'll fix this in the next commit.

This test would fail on master for multiple reasons.
2023-03-07 09:49:34 +01:00
Stefan Haller
6bd1c1d068 Remove parameters that are no longer needed
All callers in this file now use reverseOnGenerate=false and
keepOriginalHeader=true, so hard-code that in the call to ModifiedPatchForLines
and get rid of the parameters.
2023-03-07 09:49:34 +01:00
Stefan Haller
5d692e8961 Remove the keepOriginalHeader retry loop
The loop is pointless for two reasons:
- git apply --3way has this fallback built in already. If it can't do a
  three-way merge, it will fall back to applying the patch normally.
- However, the only situation where it does this is when it can't do a 3-way
  merge at all because it can't find the necessary ancestor blob. This can only
  happen if you transfer a patch between different repos that don't have the
  same blobs available; we are applying the patch to the same repo that is was
  just generated from, so a 3-way merge is always possible. (Now that we fixed
  the bug in the previous commit, that is.)

But the retry loop is not only pointless, it was actually harmful, because when
a 3-way patch fails with a conflict, git will put conflict markers in the
patched file and then exit with a non-zero exit status. So the retry loop would
try to patch the already patched file again, and this almost certainly fails,
but with a cryptic error message such as "error: main.go: does not exist in
index".
2023-03-07 09:49:34 +01:00
Stefan Haller
9cc33c479b Use forward patches and --reverse flag for partial patches too
There's no reason to have two different ways of applying patches for whole-file
patches and partial patches; use --reverse for both. Not only does this simplify
the code a bit, but it fixes an actual problem: when reverseOnGenerate and
keepOriginalHeader are both true, the generated patch header is broken (the two
blobs in the line `index 6d1959b..6dc5f84 100644` are swapped). Git fails to do
a proper three-way merge in that case, as it expects the first of the two blobs
to be the common ancestor.

It would be possible to fix this by extending ModifiedPatchForLines to swap the
two blobs in this case; but this would prevent us from concatenating all patches
and apply them in one go, which we are going to do later in the branch.
2023-03-07 09:49:34 +01:00
Stefan Haller
c79e360584 Add patch option WillBeAppliedReverse
It's not used yet, but covered with tests already.
2023-03-07 09:49:34 +01:00
Stefan Haller
f76cc27956 Bundle the reverse and keepOriginalHeader flags into a PatchOptions struct
We are going to add one more flag in the next commit.

Note that we are not using the struct inside patch_manager.go; we keep passing
the individual flags there. The reason for this will become more obvious later
in this branch.
2023-03-07 09:49:34 +01:00
Stefan Haller
5a50bfd179 Fix opening the current test file from the integration test gui 2023-03-07 09:49:34 +01:00
Jesse Duffield
c36333af3d
Merge pull request #2433 from Ryooooooga/subcommits-limit 2023-03-06 18:22:57 +11:00
Jesse Duffield
4d78d76a44
Merge pull request #2486 from humblepenguinn/master 2023-03-06 17:34:08 +11:00
Humble Penguin
dfe5c805c4 generated cheatsheets and ran code formatting 2023-03-05 07:06:34 +05:00