jesseduffield.lazygit/pkg/gui/controllers/helpers
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
..
amend_helper.go standardise helper args 2023-04-30 13:19:53 +10:00
app_status_helper.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
bisect_helper.go split context common from helper common 2023-04-30 13:19:53 +10:00
cherry_pick_helper.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
commits_helper.go Retain commit message when cycling history 2023-04-30 13:19:54 +10:00
confirmation_helper.go Introduce filtered list view model 2023-07-03 12:54:13 +10:00
credentials_helper.go Handle pending actions properly in git commands that require credentials 2023-07-08 22:54:52 +10:00
diff_helper.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
files_helper.go standardise helper args 2023-04-30 13:19:53 +10:00
gpg_helper.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
helpers.go Introduce filtered list view model 2023-07-03 12:54:13 +10:00
host_helper.go standardise helper args 2023-04-30 13:19:53 +10:00
merge_and_rebase_helper.go Show menu instead of prompt when there are conflicts in a rebase or merge 2023-06-01 10:51:48 +02:00
merge_conflicts_helper.go Fix race condition 2023-05-16 21:01:38 +10:00
mode_helper.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
patch_building_helper.go Disregard the "ignore whitespace" option in the patch building panel 2023-05-19 18:22:28 +02:00
record_directory_helper.go split context common from helper common 2023-04-30 13:19:53 +10:00
refresh_helper.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
refs_helper.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
repos_helper.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
search_helper.go Add integration tests for searching/filtering 2023-07-03 12:54:14 +10:00
snake_helper.go split context common from helper common 2023-04-30 13:19:53 +10:00
staging_helper.go Refresh staging panel when committing 2023-04-30 13:19:54 +10:00
suggestions_helper.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
tags_helper.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
update_helper.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
upstream_helper.go standardise helper args 2023-04-30 13:19:53 +10:00
upstream_helper_test.go Add option to (un)set upstream for a local branch 2022-04-11 14:04:06 +02:00
view_helper.go standardise helper args 2023-04-30 13:19:53 +10:00
window_arrangement_helper.go Introduce filtered list view model 2023-07-03 12:54:13 +10:00
window_helper.go move side window actions to controllers package 2023-04-30 13:19:53 +10:00
working_tree_helper.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00