Commit graph

1281 commits

Author SHA1 Message Date
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 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 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 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 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 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 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 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
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 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 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
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 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 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
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
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 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 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 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 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 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 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
Amirzhan Aliyev 62cc036254 fix: typo EnteRefName 2023-06-28 18:54:21 +06: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 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 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 a694c458dd Support authors and tags in custom command suggestions preset 2023-06-07 10:18:01 +10: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 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 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 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 ee11046d35 Refactor interface for ApplyPatch 2023-05-20 20:54:39 +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
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
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
Jesse Duffield 5dacbb6293 merge master into refactor-better-encapsulation 2023-05-02 19:05:42 +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 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 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 037cd99138 move quit actions to controller 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 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 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 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
Stefan Haller dad7a70bf8 Implement moving commits up/down 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 d50c58b4c6 Implement "edit commit" in terms of the new EditRebase function 2023-04-29 07:28:33 +02:00
Stefan Haller 21072226d2 Don't allow resetting non-HEAD commits (including rebase todos) during rebase 2023-04-18 17:34:07 +02:00
AzraelSec 28501fbf77 chore: add focus on local commits after interactively rebase 2023-04-15 10:42:36 +02:00
AzraelSec a3fdf91714 feat: allow to perform a rebase with breaking before the first commit 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 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
Jesse Duffield bd62b519de
Merge pull request #2496 from jesseduffield/feature/prevent-history-custom-command 2023-04-13 21:25:35 +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 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 659d668e16 Implement edit presets 2023-04-13 13:14:00 +02: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 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 a82d952f48
Merge pull request #2495 from jesseduffield/feature/remove-altreturn 2023-03-20 20:11:35 +11:00
Jesse Duffield 60f902f026 rename patch manager to patch builder 2023-03-19 16:35:57 +11:00
Jesse Duffield 73c7dc9c5d refactor patch code 2023-03-19 16:30:39 +11:00
Luka Markušić f314cb3763 Remove alternative confirmation and return keymappings 2023-03-09 10:32:00 +01: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 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
Jesse Duffield c36333af3d
Merge pull request #2433 from Ryooooooga/subcommits-limit 2023-03-06 18:22:57 +11:00
Stefan Haller 723504a290 Keep side context in context stack when pushing a main context
This fixes accordion mode for the commit files panel. When entering a file, the
commit files panel should stay expanded.
2023-03-04 15:07:48 +01:00
Ryooooooga a624e0457f
feat(subcommits): load unlimited sub-commits 2023-02-27 15:29:00 +09:00
Jesse Duffield 037e957282 fix PullMergeConflict integration test 2023-02-25 11:39:24 +11:00
Jesse Duffield 78f3a7a478 migrate interactive rebase integration tests 2023-02-22 19:36:31 +11:00
Jesse Duffield 38c7030b0f mention path in tooltips 2023-02-20 19:28:45 +11:00
Luka Markušić 31b8524fe6 Add tooltips for discarding 2023-02-20 19:28:45 +11:00
Luka Markušić 0ae34aeeb7 Make discarding items less error prone
The menu is opened by `d` so this makes it harder to mess things up by
accidentally pressing `dd`.
2023-02-20 19:28:45 +11:00
Jesse Duffield e1c376ef54
Merge pull request #2453 from stefanhaller/allow-rebasing-to-first-commit 2023-02-20 19:21:37 +11:00
Jesse Duffield 0b55eaca1d add create tag from commit test 2023-02-20 19:01:08 +11:00
Stefan Haller c5cd217a65 Allow squashing fixups above the first commit of a repo
This includes amending changes into a given commit, since that's implemented in
terms of the former.
2023-02-20 08:29:43 +01:00
Jesse Duffield 9e1e20fef2
Merge pull request #2421 from Ryooooooga/tag-on-branch 2023-02-20 18:20:16 +11:00
Stefan Haller dd61c49a15 Better error message for trying to squash or fixup the first commit
It's not so much the total number of commits that matters here, it's just
whether we are on the first one. (This includes the other condition.)

This allows us to get rid of the condition in rebase.go.
2023-02-20 07:40:04 +01:00
Ryooooooga 67b08ac239
feat: support to create tag on branch 2023-02-19 23:31:46 +09:00
Stefan Haller 67b8ef449c Edit by breaking after current commit
Instead of rebasing from the commit below the current one and then setting the
current one to "edit", we rebase from the current one and insert a "break" after
it. In most cases the behavior is exactly the same as before, except that the
new method also works if the current commit is a merge commit. This is useful if
you want to create a new commit at the very beginning of your branch (by editing
the last commit before your branch).
2023-02-19 10:21:01 +01:00
Jesse Duffield 65bd0ab431 migrate undo test 2023-02-19 15:48:09 +11:00
Jesse Duffield bff076c70a rename key to Pull 2023-02-19 11:42:00 +11:00
stk b499eba1a8 Select next stageable line correctly after staging a range of lines
We already have this very convenient behavior of jumping to the next stageable
line after staging something. However, while this worked well for staging
single lines or hunks, it didn't work correctly when staging a range of lines;
in this case we want to start searching from the first line of the range.
2023-02-15 21:29:00 +01:00
Ryooooooga 39c20bc634
chore: change to work return-alt1 on all views 2023-02-11 21:19:47 +09:00
Jesse Duffield 5e2254395a fix linting issue 2023-02-09 21:45:14 +11:00
stk 67fb28e2b8 Add user config gui.skipRewordInEditorWarning 2023-01-26 09:01:22 +01:00
stk b8d33b8f7b Extract helper function doRewordEditor
No behavior change, just a preparation for the next commit.
2023-01-22 15:59:32 +01:00
Jesse Duffield af5b3be286 integrate snake game into lazygit 2022-12-30 12:18:59 +11:00
Jesse Duffield fb15a2f4f8
Merge pull request #2326 from Ryooooooga/fix-scroll
fix https://github.com/jesseduffield/lazygit/issues/2309
2022-12-24 19:20:23 +11:00
Ryooooooga 7bdba1abe4
fix(#2309): fix diff scroll 2022-12-20 22:25:49 +09:00
Jesse Duffield 5679efe174
Merge pull request #2239 from bdach/u2f-key-prompts
close https://github.com/jesseduffield/lazygit/issues/2230
2022-12-20 21:44:29 +11:00
Arnaud PERALTA 0af63daf18 workingtree controller fixed with new references for commit in staged menu 2022-12-01 09:12:18 +11:00
Arnaud PERALTA 8b894d7bf5 wip: commit logic in helper and reported in files/staging controllers 2022-12-01 09:12:18 +11:00
Jesse Duffield 65d6d7fb2d fix ignore file keybinding 2022-11-30 19:36:35 +11:00
Bartłomiej Dach 1a1f042f49 Add credential prompts for U2F-backed SSH keys
The 8.2 release of OpenSSH added support for FIDO/U2F hardware
authenticators, which manifests in being able to create new types of SSH
key, named `ecdsa-sk` nad `ed25519-sk`. This is relevant to lazygit,
as those SSH keys can be used to authorise git operations over SSH, as
well as signing git commits. Actual code changes are required for
correct support, as the authentication process for these types of keys
is different than the process for types supported previously.

When an operation requiring credentials is initialised with a U2F
authenticator-backed key, the first prompt is:

	Enter PIN for ${key_type} key ${path_to_key}:

at which point the user is supposed to enter a numeric (and secret) PIN,
specific to the particular FIDO/U2F authenticator using which the SSH
keypair was generated. Upon entering the correct key, the user is
supposed to physically interact with the authenticator to confirm
presence. Sometimes this is accompanied by the following text prompt:

	Confirm user presence for key ${key_type} ${key_fingerprint}

This second prompt does not always occur and it is presumed that the
user will know to perform this step even if not prompted specifically.
At this stage some authenticator devices may also begin to blink a LED
to indicate that they're waiting for input.

To facilitate lazygit's interoperability with these types of keys, add
support for the first PIN prompt, which allows "fetch", "pull", and
"push" git operations to complete.
2022-11-30 13:34:32 +11:00
Ryooooooga 52a2e4c1dc fix: fix ambiguous branch name
test: add an integration test for checkout branch by name

fix: fix full ref name of detached head

refactor: refactor current branch loader

chore: use field name explicitly
2022-11-14 19:05:07 +11:00
Jesse Duffield b33ec5a050
Merge pull request #1980 from ajhynes7/stash-untracked-changes 2022-11-14 18:46:53 +11:00
sudoburt 3e73dacce3 Merge loaders package into git_commands package 2022-11-14 18:11:45 +11:00
Andrew Hynes 684d1e955e lint: try deleting blank line 2022-11-13 19:51:30 -03:30
Andrew Hynes 3c436b3457 lint: delete unused argument from handleStashSave 2022-11-13 11:02:06 -03:30
Jesse Duffield d26350502c stop switching focus to commits view when resetting 2022-11-13 03:26:50 +00:00
Andrew Hynes a47e72892a
Merge branch 'master' into stash-untracked-changes 2022-11-01 16:08:34 -02:30
Ryooooooga 3103398e31
chore: refactor rename stash 2022-10-16 09:30:04 +09:00
Ryooooooga eceb3a5aa6
chore: refactor rename stash 2022-10-16 09:12:43 +09:00
Ryooooooga 11316b7a48
feat: add rename stash 2022-10-16 09:12:42 +09:00
Andrew Hynes 8c46a0110d
Merge branch 'master' into stash-untracked-changes 2022-10-06 22:59:06 -02:30
jiepeng bc8050d8ac typo 2022-09-17 15:10:41 -07:00
jiepeng b8900baf1a remove deprecated calls 2022-09-17 15:10:41 -07:00
Andrew Hynes e189546acb refactor: move checks for clean working tree 2022-09-15 21:48:49 -02:30
Andrew Hynes c7733aa5e5 refactor: rename method to StashIncludeUntrackedChanges 2022-09-15 21:48:49 -02:30
Andrew Hynes 50cf7ac5bc refactor: change command order 2022-09-15 21:48:49 -02:30
Andrew Hynes c7fd218308 fix: add condition to if statement 2022-09-15 21:48:49 -02:30
Andrew Hynes 7ddb80a13e feat: add stash option to include untracked changes 2022-09-15 21:48:48 -02:30
Luka Markušić 0ff5b74d80 IgnoreOrExclude should be a menu 2022-08-11 14:23:02 +02:00
Jesse Duffield 7410acd1aa move merge conflicts code into controller 2022-08-07 11:16:03 +10:00
Jesse Duffield 445a625b56 rename merging context to mergeConflicts 2022-08-06 18:05:00 +10:00
Jesse Duffield 524bf83a4a refactor to only have one context per view 2022-08-06 13:49:11 +10:00
Jesse Duffield debc58b6c5 fix popup focus issue 2022-08-01 22:09:48 +10:00
Jesse Duffield 682be18507 refactor to use generics for file nodes
use less generic names
2022-07-31 19:43:14 +10:00
Jesse Duffield 7077ea428f add optimistic rendering for staging and unstaging files 2022-07-31 14:34:57 +10:00
Jesse Duffield 95678b1b43
Merge pull request #2065 from jesseduffield/fix-rewording-merge-commit-with-editor
Fix rewording a merge commit with editor
2022-07-30 19:51:59 +10:00
Luka Markušić cc377b5c49 Fix rewording a merge commit with editor 2022-07-30 08:43:42 +02:00
Luka Markušić 1f482e585e Fix github linter errors 2022-07-30 08:10:29 +02:00
Juan Sanchez Montalvo 11d766053e Allow adding a file to the .git/info/exclude file 2022-07-05 19:33:44 +10:00
Jesse Duffield cdec70cc06
Merge pull request #1975 from mark2185/fix-unmatching-remote-branch-name 2022-06-09 20:12:56 +10:00
Jesse Duffield 9591cc381a support setting the author of a commit
update copy
2022-06-09 19:12:20 +10:00
Luka Markušić 55a941d5dc Fetch the correct remote branch 2022-06-01 20:35:09 +02:00
Ryooooooga 9693afd671
fix: fix lint error 2022-05-18 20:34:35 +09:00
Jesse Duffield f31dcd3091
Merge pull request #1930 from mark2185/feature/discard-staged-only 2022-05-15 20:33:25 +10:00
Luka Markušić 241d182da7 Make tooltip i18n-able 2022-05-15 12:16:20 +02:00
Ryooooooga 61970a4439
fix: fix ambiguous refname 2022-05-13 21:05:51 +09:00
Luka Markušić ca191159f5 Discard staged changes only 2022-05-08 14:24:28 +02:00
Jesse Duffield 6f8063217d rename displayString to label for menu items 2022-05-08 14:26:18 +10:00
Jens Pfeifle 7c573a5bea Add command to reset the commit author from the commits panel. 2022-05-08 13:29:56 +10:00
Jesse Duffield f257740ea7 add tooltip view for showing menu item descriptions 2022-05-08 13:24:36 +10:00
Jesse Duffield 0940e0182b
Merge pull request #1870 from mark2185/feature/stash-unstaged 2022-05-06 20:17:33 +10:00
Jesse Duffield f7fae0b82e
Merge pull request #1869 from mark2185/feature/unset-upstream 2022-05-06 20:14:13 +10:00
Jesse Duffield 4dd09ee0d5 allow copying commit author to clipboard 2022-05-01 14:14:29 +10:00
Jesse Duffield e68093fe99 add scrollbars 2022-04-16 17:29:17 +10:00
Luka Markušić 1ae2dc9941 The four horsemen of stashing 2022-04-14 21:45:55 +02:00
Luka Markušić e114b5b5e8 Refresh BRANCHES and COMMITS after (un)staging upstream 2022-04-13 15:54:32 +02:00
Luka Markušić c4b958e3fd There's gotta be a better way for initial content 2022-04-13 15:21:01 +02:00
Luka Markušić f83308c8df Add option to (un)set upstream for a local branch 2022-04-11 14:04:06 +02:00
Luka Markušić 6f7038c827 Add option to stash only unstaged files 2022-04-10 09:35:59 +02:00
Ryooooooga 4835fc00b8 introduce Ref interface 2022-04-02 17:04:42 +11:00
Moritz Haase 8fb2acc224 pkg/gui: Rename IPopupHandler::Ask() to Confirm()
Follow the JavaScript naming scheme for user interaction (alert, prompt,
confirm) as discussed in #1832.
2022-03-30 20:13:43 +11:00
Jesse Duffield 7c3d14ee19 allow amending and reverting commits when filtering by file 2022-03-27 18:50:29 +11:00
Jesse Duffield 860d1e0145 fix copy for merge confirmation 2022-03-27 18:16:16 +11:00
Jesse Duffield e011acbab2 better logging for stash flow 2022-03-27 18:16:16 +11:00
Jesse Duffield 3e5d4b2c74 add menu keybindings for various things 2022-03-27 18:16:16 +11:00
Jesse Duffield 9c226eed37 allow menu to store keybindings for quick menu navigation 2022-03-27 18:16:16 +11:00
Jesse Duffield 0dfb7c08b7 remove controllers struct 2022-03-27 18:16:16 +11:00
Jesse Duffield f0a4dcfdc3 refactor menu context 2022-03-27 18:16:16 +11:00
Jesse Duffield 2b3d457aa4 honour push.default matching config value 2022-03-27 14:58:20 +11:00
Jesse Duffield 51baa8c17d update cheatsheet 2022-03-26 18:00:46 +11:00
Jesse Duffield ad7703df65 show namesake for child views 2022-03-26 18:00:46 +11:00
Jesse Duffield 13b90ac37f support viewing commits of reflog entry and show better view title 2022-03-26 18:00:46 +11:00
Jesse Duffield e039429885 better wording again 2022-03-26 17:22:42 +11:00
Jesse Duffield e0b05f4464 fix cherry picking bug 2022-03-26 17:22:42 +11:00
Jesse Duffield 077b6eb8a3 refactor to make code clearer 2022-03-26 17:22:42 +11:00
Jesse Duffield 45dab51214 add basic commits controller for handling actions that apply to all commit contexts 2022-03-26 17:22:42 +11:00
Luka Markušić 540edb0bf4 Add copy commit attributes option 2022-03-26 17:22:42 +11:00
Jesse Duffield e392b9f86a no more filterThenMap 2022-03-24 20:14:41 +11:00
Jesse Duffield 94a53484a1 would you believe that I'm adding even more generics 2022-03-24 20:14:41 +11:00
Jesse Duffield 1b75ed3740 many more generics 2022-03-24 20:14:41 +11:00
Jesse Duffield eda8f4a5d4 lots more generics 2022-03-24 20:14:41 +11:00
Jesse Duffield c7a629c440 make more use of generics 2022-03-24 20:14:41 +11:00
Jesse Duffield f113ff21bf add confirmation before performing undo or redo action 2022-03-24 09:45:27 +11:00
Jesse Duffield 12ecd665c8 safe reword 2022-03-23 23:43:21 +11:00
Jesse Duffield cc5d13c833 allow adding whole diff to patch
this was causing a panic

add integration test for toggling all commit files
2022-03-23 23:36:58 +11:00
Jesse Duffield a34bdf1a04 update linters 2022-03-19 12:12:57 +11:00
Jesse Duffield d93fef4c61 use generics to DRY up context code 2022-03-19 12:12:57 +11:00
Jesse Duffield 36c149836a softcode keybinding 2022-03-17 19:13:40 +11:00
Jesse Duffield ea503633aa move keybindings 2022-03-17 19:13:40 +11:00
Jesse Duffield 59d4df2a44 fix click handling 2022-03-17 19:13:40 +11:00
Jesse Duffield cf00949b85 fix integration tests 2022-03-17 19:13:40 +11:00
Jesse Duffield c7b03bd3c2 rename handlers 2022-03-17 19:13:40 +11:00
Jesse Duffield 8fd6338527 move workspace reset menu into controller 2022-03-17 19:13:40 +11:00
Jesse Duffield ee1337b931 add remote branches controller 2022-03-17 19:13:40 +11:00
Jesse Duffield 4805db7d97 use correct context 2022-03-17 19:13:40 +11:00
Jesse Duffield 46e9946854 refactor credential handling 2022-03-17 19:13:40 +11:00
Jesse Duffield bff5351ab3 better naming 2022-03-17 19:13:40 +11:00
Jesse Duffield d991d74b06 add commit message controller 2022-03-17 19:13:40 +11:00
Jesse Duffield ecaff7fc6c add commit files controller 2022-03-17 19:13:40 +11:00
Jesse Duffield c685a413c9 stash controller 2022-03-17 19:13:40 +11:00
Jesse Duffield a643957f89 include stash in commitish controller 2022-03-17 19:13:40 +11:00
Jesse Duffield e842d1bc9e move git flow 2022-03-17 19:13:40 +11:00
Jesse Duffield 8a555dd62e refactor 2022-03-17 19:13:40 +11:00
Jesse Duffield bef26b9634 add common commit controller 2022-03-17 19:13:40 +11:00
Jesse Duffield 1253100431 cleanup 2022-03-17 19:13:40 +11:00
Jesse Duffield eab00de273 reflog controller 2022-03-17 19:13:40 +11:00
Jesse Duffield 371b8d638b more consistent naming 2022-03-17 19:13:40 +11:00
Jesse Duffield 3188526ecb fix cheatsheet crash 2022-03-17 19:13:40 +11:00
Jesse Duffield 722410aded refactor controllers 2022-03-17 19:13:40 +11:00
Jesse Duffield b93b8cc00a controller for viewing sub commits 2022-03-17 19:13:40 +11:00
Jesse Duffield cd31a762b9 rename OSCommand field to os 2022-03-17 19:13:40 +11:00
Jesse Duffield d82f175e79 refactor contexts 2022-03-17 19:13:40 +11:00
Jesse Duffield 482bdc4f1e more refactoring 2022-03-17 19:13:40 +11:00
Jesse Duffield 8e3484d8e9 add global controller 2022-03-17 19:13:40 +11:00
Jesse Duffield 226985bf76 refactor keybindings 2022-03-17 19:13:40 +11:00
Jesse Duffield 2db4636815 no more indirection 2022-03-17 19:13:40 +11:00
Jesse Duffield 2a1e3faa0c resetting controllers on new repo 2022-03-17 19:13:40 +11:00
Jesse Duffield 0a8cff6ab6 some more refactoring 2022-03-17 19:13:40 +11:00
Jesse Duffield b5515da00b move commit files context into new structure 2022-03-17 19:13:40 +11:00
Jesse Duffield c084abb378 move more view model logic into the files view model 2022-03-17 19:13:40 +11:00
Jesse Duffield 8ea7b7a62e migrate files context to new structure 2022-03-17 19:13:40 +11:00
Jesse Duffield e187293456 moving more into controllers package 2022-03-17 19:13:40 +11:00
Jesse Duffield f97de692e3 move helpers into their own struct 2022-03-17 19:13:40 +11:00
Jesse Duffield 2692637fbe standardise naming 2022-03-17 19:13:40 +11:00
Jesse Duffield 77d0732fa8 add actions abstraction 2022-03-17 19:13:40 +11:00
Jesse Duffield 138be04e65 refactor contexts code 2022-03-17 19:13:40 +11:00
Jesse Duffield 1a74ed3214 avoid deadlock 2022-03-17 19:13:40 +11:00
Jesse Duffield a2318d75b5 fix some things 2022-03-17 19:13:40 +11:00
Jesse Duffield 1dd7307fde start moving commit panel handlers into controller
more

and more

move rebase commit refreshing into existing abstraction

and more

and more

WIP

and more

handling clicks

properly fix merge conflicts

update cheatsheet

lots more preparation to start moving things into controllers

WIP

better typing

expand on remotes controller

moving more code into controllers
2022-03-17 19:13:40 +11:00
Jesse Duffield a90b6efded start refactoring gui 2022-03-17 19:13:40 +11:00