1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-21 12:16:54 +02:00

42 Commits

Author SHA1 Message Date
Stefan Haller
e987d4b519 Swap position of checkout-commit and checkout-branch menu items
Jesse's comment from https://github.com/jesseduffield/lazygit/issues/4237:

We recently added a new option to check out a commit's branch from within the
commits, reflog, and sub-commits panels:

https://github.com/user-attachments/assets/0a5cf3f2-6803-4709-ae5a-e4addc061012

After using it for some time, I find it annoying that the default option has
changed. I rarely find myself wanting to check out a branch from the commits
panel, and it's rarer still to want to check out a branch from the reflog and
sub-commits panel. Although there may be use cases for this, it is jarring that
something you can always do (checkout the commit) is harder to do than something
that you can sometimes do (checkout the branch).

We've also had a user complain (see
https://github.com/jesseduffield/lazygit/pull/4117) about their muscle-memory
being broken by the recent change, and I have also fallen victim to this. I
don't think that the new branch checkout option is sufficiently useful to
dislodge the existing keybinding, so let's swap them.
2025-02-10 13:35:01 +01:00
Nathan Baulch
508cdb40a8 Fix typos 2025-01-03 10:50:36 +11:00
Sebastian Flügge
f4c8287143 Allow to switch branches in Commit View
When the user checks out a commit which has a local branch ref attached
to it, they can select between checking out the branch or checking out
the commit as detached head.
2025-01-01 14:55:12 +01:00
Stefan Haller
d4ef8e53d5 Remove return value of Alert/Confirm/Prompt
This might seem controversial; in many cases the client code gets longer,
because it needs an extra line for an explicit `return nil`. I still prefer
this, because it makes it clearer which calls can return errors.
2024-09-06 08:45:48 +02:00
Stefan Haller
371998e635 Remove return value of IContextMgr.Push/Pop et. al. 2024-09-06 08:45:48 +02:00
Stefan Haller
b91beb68e1 Remove return value of HandleRender 2024-09-06 08:45:48 +02:00
Brandon
e8e39f5ce2 Offer autostash option when creating new branch 2024-09-03 09:05:53 +02:00
Brandon
370ab2d19c Simplify CheckoutRef 2024-09-03 09:05:53 +02:00
Brandon
ae61da7485 Fix cancelled autostash resulting in stuck inline status 2024-08-27 10:28:22 +02:00
Stefan Haller
f98b57aa5e Change direct access to Common.UserConfig to a getter
This will allow us to turn the field into an atomic.Value for safe concurrent
access.
2024-08-18 10:24:52 +02:00
Stefan Haller
7ed94c0410 Replace CurrentContext() with Context().Current() 2024-08-17 11:14:51 +02:00
Stefan Haller
bd36b8a95e Replace PushContext() with Context().Push() 2024-08-17 11:14:50 +02:00
Elliot Cubit
5959f7bc8e Allow setting a default name when creating new branches 2024-07-06 21:06:28 +10:00
T.
b26ff43d9e Update tracking behaviour for branches created from remote branches
The current behaviour when creating a new branch off of a remote branch
is to always track the branch it was created from.

For example, if a branch 'my_branch' is created off of the remote branch
'fix_crash_13', then 'my_branch' will be tracking the remote
'fix_crash_13' branch.

It is common practice to have both the local and remote branches named
the same when the local is tracking the remote one. Therefore, it is
reasonable to expect that 'my_branch' should not track the remote
'fix_crash_13' branch.

The new behaviour when creating a new branch off of a remote branch is
to track the branch it was created from only if the branch names match.
If the branch names DO NOT match then the newly created branch will not
track the remote branch it was created from.

For example, if a user creates a new branch 'fix_crash_13' off of the
remote branch 'fix_crash_13', then the local 'fix_crash_13' branch will
track the remote 'fix_crash_13' branch.
However, if the user creates a new branch called 'other_branch_name' off
of the remote branch 'fix_crash_13', then the local 'other_branch_name'
branch will NOT track the remote 'fix_crash_13' branch.
2024-07-04 22:34:36 +02:00
Stefan Haller
68c966567c Show radio buttons in the sort order menu for branches 2024-06-23 12:53:15 +02:00
Stefan Haller
ddd6323aa5 Add prompt to the remote branch checkout menu 2024-06-23 12:33:16 +02:00
Stefan Haller
82a3d33ce3 Remove calls to Error()
Now that we have an error handler set, we can simply let them bubble up all the
way to gocui.
2024-04-18 10:10:30 +02:00
Stefan Haller
6932e04708 Refresh after creating local branch, before checking it out
This way we see the local branch immediately when switching to the branches
view, and we see an inline waiting status on it when checking it out.
2024-03-17 07:53:38 +01:00
Stefan Haller
30db7234d9 Show inline waiting status when checking out a local branch 2024-03-17 07:53:38 +01:00
Stefan Haller
e42cbf95ae When checking out a remote branch by name, ask the user how
The choices are to create a new local branch that tracks the remote, or a
detached head.
2024-03-17 07:53:38 +01:00
Stefan Haller
9362aede8f Add tooltips for reset menu items 2024-02-21 09:55:04 +01:00
Stefan Haller
dfabe8db70 Change "git reset" default to --mixed
Calling "git reset" on the command line (without further arguments) defaults to
--mixed, which is reason enough to make it the default for us, too.

But I also find myself using --mixed more often than --soft. The main use case
for me is that I made a bunch of WIP commits, and want to turn them into real
commits when I'm done hacking. I select the last commit before the WIP commits
and reset to it, leaving all changes of all those commits in the working
directory. Since I want to start staging things from there, I prefer those
modifications to be unstaged at that point, which is what --mixed does.
2024-02-21 09:55:04 +01:00
Stefan Haller
2c9b4770bc Keep same branch selected when refreshing branches
This wasn't necessary before, because the only available branch sorting option
was by recency, so the sort order couldn't change except by checking out
branches. Now, you can sort by committer date, so the branch order can change by
fetching; in this case it's important to keep the same branch selected. One
important use case is to rebase the checked-out branch onto master; you select
master, press "f" to fetch it (this can now change its position in the list),
and then press "r" to rebase. To make this work smoothly it's important to keep
master selected after pressing "f".
2024-01-19 09:25:07 +01:00
Jesse Duffield
54bd94ad24 Add SetSelection function for list contexts and use it in most places
The only time we should call SetSelectedLineIdx is when we are happy for a
select range to be retained which means things like moving the selected line
index to top top/bottom or up/down a page as the user navigates.

But in every other case we should now call SetSelection because that will
set the selected index and cancel the range which is almost always what we
want.
2024-01-19 10:47:21 +11:00
Alex March
36a29f225b Add a sort order menu for local branches 2023-12-27 15:25:29 +01:00
Alex March
3fe491fcb2 Implement a sort order menu for remote branches 2023-12-22 16:30:20 +09:00
Cal Courtney
c3ca77d6bf Replace whitespace with '-' when renaming a branch 2023-09-05 14:57:18 +01:00
Jesse Duffield
e33fe37a99 Standardise on using lo for slice functions
We've been sometimes using lo and sometimes using my slices package, and we need to pick one
for consistency. Lo is more extensive and better maintained so we're going with that.

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

I've also moved the remaining methods into the utils package.
2023-07-30 18:51:23 +10:00
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
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
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
d26350502c stop switching focus to commits view when resetting 2022-11-13 03:26:50 +00:00
Jesse Duffield
6f8063217d rename displayString to label for menu items 2022-05-08 14:26:18 +10: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
3e5d4b2c74 add menu keybindings for various things 2022-03-27 18:16:16 +11:00
Jesse Duffield
1b75ed3740 many more generics 2022-03-24 20:14:41 +11:00
Jesse Duffield
a34bdf1a04 update linters 2022-03-19 12:12:57 +11:00
Jesse Duffield
371b8d638b more consistent naming 2022-03-17 19:13:40 +11:00
Jesse Duffield
722410aded refactor controllers 2022-03-17 19:13:40 +11:00