lazygit/pkg/commands/git_commands
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
..
bisect.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
bisect_info.go simplify 2022-03-24 20:14:41 +11:00
branch.go show commits against branches 2023-06-01 19:21:24 +10:00
branch_loader.go show commits against branches 2023-06-01 19:21:24 +10:00
branch_loader_test.go show commits against branches 2023-06-01 19:21:24 +10:00
branch_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
commit.go Always show branch heads in diff pane 2023-06-28 09:44:06 +02:00
commit_file_loader.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
commit_file_loader_test.go Merge loaders package into git_commands package 2022-11-14 18:11:45 +11:00
commit_loader.go Use comment char config on interactive rebase 2023-07-02 02:07:32 -03:00
commit_loader_test.go Use remote upstreams of main branches to determine merged status of commits 2023-06-26 09:02:46 +02:00
commit_test.go Always show branch heads in diff pane 2023-06-28 09:44:06 +02:00
common.go feat: add GitVersion struct 2022-12-30 20:01:14 +09:00
config.go Use comment char config on interactive rebase 2023-07-02 02:07:32 -03:00
custom.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
deps_test.go Refactor interface for ApplyPatch 2023-05-20 20:54:39 +10:00
diff.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
file.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
file_loader.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
file_loader_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
file_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
flow.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
flow_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
git_command_builder.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
git_command_builder_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
patch.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
patch_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
rebase.go Use comment char config on interactive rebase 2023-07-02 02:07:32 -03:00
rebase_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
reflog_commit_loader.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
reflog_commit_loader_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
remote.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
remote_loader.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
stash.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
stash_loader.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
stash_loader_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
stash_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
status.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
submodule.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
sync.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
sync_test.go Add --all to "git fetch" command when not fetching a specific remote 2023-06-01 10:13:14 +02:00
tag.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
tag_loader.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
tag_loader_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
version.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
version_test.go feat: add GitVersion struct 2022-12-30 20:01:14 +09:00
working_tree.go Fix discard logic 2023-05-23 20:23:08 +10:00
working_tree_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00