summaryrefslogtreecommitdiffstats
path: root/pkg/tasks
AgeCommit message (Collapse)Author
2024-05-15Use ScanLinesAndTruncateWhenLongerThanBuffer instead of bufio.ScanLinesStefan Haller
2024-04-18Make OnWorker callback return an errorStefan Haller
This lets us get rid of a few more calls to Error(), and it simplifies things for clients of OnWorker: they can simply return an error from their callback like we do everywhere else.
2024-01-24Refactor repo_paths.go to use git rev-parseJohn Whitley
This changes GetRepoPaths() to pull information from `git rev-parse` instead of effectively reimplementing git's logic for pathfinding. This change fixes issues with bare repos, esp. versioned homedir use cases, by aligning lazygit's path handling to what git itself does. This change also enables lazygit to run from arbitrary subdirectories of a repository, including correct handling of symlinks, including "deep" symlinks into a repo, worktree, a repo's submodules, etc. Integration tests are now resilient against unintended side effects from the host's environment variables. Of necessity, $PATH and $TERM are the only env vars allowed through now.
2023-07-30Remove secureexec packageJesse Duffield
From the go 1.19 release notes: Command and LookPath no longer allow results from a PATH search to be found relative to the current directory. This removes a common source of security problems but may also break existing programs that depend on using, say, exec.Command("prog") to run a binary named prog (or, on Windows, prog.exe) in the current directory. See the os/exec package documentation for information about how best to update such programs.
2023-07-23Fix crash caused by simultaneous read/write of scanner bufferJesse Duffield
2023-07-22Fix rendering to main view on windowsv0.39.2Andrew Savinykh
2023-07-10RefactorJesse Duffield
2023-07-10Use an interface for tasks instead of a concrete structJesse Duffield
By using an interface for tasks we can use a fake implementation in tests with extra methods
2023-07-09Use first class task objects instead of global counterJesse Duffield
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-09Fix race conditionJesse Duffield
We had some test flakiness involving the index.lock file which is fixed by this commit. We shouldn't be accessing newTaskID without the mutex, although I'm surprised that this actually fixes the issue. Surely we don't have tasks (which typically render to the main view) which use index.lock?
2023-07-08Add busy count for integration testsJesse Duffield
Integration tests need to be notified when Lazygit is idle so they can progress to the next assertion / user action.
2023-04-02prevent unnecessary re-renders of viewJesse Duffield
2023-03-21Make sure scrollbars have the right size initiallyStefan Haller
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.
2022-08-07add deadlock mutex packageJesse Duffield
write to deadlock stderr after closing gocui more deadlock checking
2022-08-06refactor to only have one context per viewJesse Duffield
2022-05-07more documentationJesse Duffield
2022-04-06chore: typo hunting ft. codespellcasswedson
2022-03-19update lintersJesse Duffield
2021-11-07add testsv0.31.2Jesse Duffield
2021-11-07restore some code that was erroneously removedJesse Duffield
2021-11-05some more throttling stuffJesse Duffield
2021-11-05render commit graphJesse Duffield
2021-11-01some refactoring in anticipation of the graph featureJesse Duffield
2021-10-19suggest files when picking a path to filter onJesse Duffield
async fetching of suggestions remove limit cache the trie for future use more more
2021-10-17stop resetting scroll all the timeJesse Duffield
2021-04-09reduce flicker without worrying about carriage returnsJesse Duffield
2021-04-08revert no-flicker due to carriage return weirdnessJesse Duffield
2021-04-06fix flicker issue in main viewJesse Duffield
2020-10-10add some safe goroutinesJesse Duffield
WIP
2020-10-02allow submodule init and show submodule diff with a prefixJesse Duffield
2020-09-29move OS commands into their own packageJesse Duffield
2020-09-26add in-built logging support for a better dev experienceJesse Duffield
2020-03-09big golangci-lint cleanupJesse Duffield
2020-03-04refactorJesse Duffield
2020-03-04supporing custom pagers step 1Jesse Duffield
2020-02-24tasks: don't use a function that requires Go 1.12Dawid Dziurla
2020-02-02more ticker improvementsJesse Duffield
2020-01-12allow fast flicking through any list panelJesse Duffield
Up till now our approach to rendering things like file diffs, branch logs, and commit patches, has been to run a command on the command line, wait for it to complete, take its output as a string, and then write that string to the main view (or secondary view e.g. when showing both staged and unstaged changes of a file). This has caused various issues. For once, if you are flicking through a list of files and an untracked file is particularly large, not only will this require lazygit to load that whole file into memory (or more accurately it's equally large diff), it also will slow down the UI thread while loading that file, and if the user continued down the list, the original command might eventually resolve and replace whatever the diff is for the newly selected file. Following what we've done in lazydocker, I've added a tasks package for when you need something done but you want it to cancel as soon as something newer comes up. Given this typically involves running a command to display to a view, I've added a viewBufferManagerMap struct to the Gui struct which allows you to define these tasks on a per-view basis. viewBufferManagers can run files and directly write the output to their view, meaning we no longer need to use so much memory. In the tasks package there is a helper method called NewCmdTask which takes a command, an initial amount of lines to read, and then runs that command, reads that number of lines, and allows for a readLines channel to tell it to read more lines. We read more lines when we scroll or resize the window. There is an adapter for the tasks package in a file called tasks_adapter which wraps the functions from the tasks package in gui-specific stuff like clearing the main view before starting the next task that wants to write to the main view. I've removed some small features as part of this work, namely the little headers that were at the top of the main view for some situations. For example, we no longer show the upstream of a selected branch. I want to re-introduce this in the future, but I didn't want to make this tasks system too complicated, and in order to facilitate a header section in the main view we'd need to have a task that gets the upstream for the current branch, writes it to the header, then tells another task to write the branch log to the main view, but without clearing inbetween. So it would get messy. I'm thinking instead of having a separate 'header' view atop the main view to render that kind of thing (which can happen in another PR) I've also simplified the 'git show' to just call 'git show' and not do anything fancy when it comes to merge commits. I considered using this tasks approach whenever we write to a view. The only thing is that the renderString method currently resets the origin of a view and I don't want to lose that. So I've left some in there that I consider harmless, but we should probably be just using tasks now for all rendering, even if it's just strings we can instantly make.