summaryrefslogtreecommitdiffstats
path: root/pkg/integration/components
AgeCommit message (Collapse)Author
2024-03-09Local-ise remote branches when checking out by namecheckout-by-nameJesse Duffield
The idea here is that in the git CLI you will often want to checkout a remote branch like origin/blah by doing `git checkout blah`. That will automatically create a local branch named blah that tracks origin/blah. Previously in the suggestions view when checking out a branch by name, we would only show local branches and remote branches like origin/blah but wouldn't show blah as an option (assuming no local branch existed with that name). This meant users would checkout origin/blah and git would check out that branch as a detached head which is rarely what you actually want. Now we give them both options. The alternative approach we could have taken is to still show the branch as origin/blah but then ask if the user wants to check out the branch as detached or as a local branch tracking the remote branch. That approach is certainly more versatile, but it's also something you can do already by going to the remote branch directly via the remotes view. Admittedly, my approach involves less work.
2024-03-07Extend submodule tests to use a submodule where name and path are differentStefan Haller
In most real-world scenarios, name and path are usually the same. They don't have to be though, and it's important to make sure we use the right one when passing arguments to git commands, so change the tests to have different name and path.
2024-01-28Show mode-specific keybinding suggestionsJesse Duffield
As part of making lazygit more discoverable, there are certain keys which you almost certainly need to press when you're in a given mode e.g. 'v' to paste commits when cherry-picking. This commit prominently shows these keybinding suggestions alongside the others in the option view. I'm using the same colours for these keybindings as is associated with the mode elsewhere e.g. yellow for rebasing and cyan for cherry-picking. The cherry-picking one is a bit weird because we also use cyan text to show loaders and app status at the bottom left so it may be confusing, but I haven't personally found it awkward from having tested it out myself. Previously we would render these options whenever a new context was activated, but now that we need to re-render options whenever a mode changes, I'm instead rendering them on each screen re-render (i.e. in the layout function). Given how cheap it is to render this text, I think it's fine performance-wise.
2024-01-25Fix error message for selected linesJesse Duffield
We had the actual and expected lines swapped around erroneously
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.
2024-01-23Better assertion logic for line selectionJesse Duffield
Previously if we marked a line with IsSelected() we would check if it was selected, but we would not check if other lines were unexpectedly selected. Now, if you use IsSelected(), we ensure that _only_ the lines you marked as such are the selected lines.
2024-01-19Standardise display of range selection across viewsJesse Duffield
We're not fully standardising here: different contexts can store their range state however they like. What we are standardising on is that now the view is always responsible for highlighting the selected lines, meaning the context/controller needs to tell the view where the range start is. Two convenient benefits from this change: 1) we no longer need bespoke code in integration tests for asserting on selected lines because we can just ask the view 2) line selection in staging/patch-building/merge-conflicts views now look the same as in list views i.e. the highlight applies to the whole line (including trailing space) I also noticed a bug with merge conflicts not rendering the selection on focus though I suspect it wasn't a bug with any real consequences when the view wasn't displaying the selection. I'm going to scrap the selectedRangeBgColor config and just let it use the single line background color. Hopefully nobody cares, but there's really no need for an extra config.
2024-01-14Use ErrorToast instead of error panel when invoking a disabled commandStefan Haller
2024-01-14Make it mandatory to acknowledge toasts in testsStefan Haller
2024-01-14Make it possible to handle toasts in integration testsStefan Haller
Use it in two selected tests to demonstrate what it looks like.
2024-01-13Add ability to start an interactive rebase onto an appropriate baseJesse Duffield
A common issue I have is that I want to move a commit from the top of my branch all the way down to the first commit on the branch. To do that, I need to navigate down to the first commit on my branch, press 'e' to start an interactive rebase, then navigate back up to the top of the branch, then move my commit back down to the base. This is annoying. Similarly annoying is moving the commit one-by-one without explicitly starting an interactive rebase, because then each individual step is its own rebase which takes a while in aggregate. This PR allows you to press 'i' from the commits view to start an interactive rebase from an 'appropriate' base. By appropriate, we mean that we want to start from the HEAD and stop when we reach the first merge commit or commit on the main branch. This may end up including more commits than you need, but it doesn't make a difference.
2024-01-12Set working directory in lazygit test commandJesse Duffield
We need to fetch our list of tests both outside of our test binary and within. We need to get the list from within so that we can run the code that drives the test and runs assertions. To get the list of tests we need to know where the root of the lazygit repo is, given that the tests live in files under that root. So far, we've used this GetLazyRootDirectory() function for that, but it assumes that we're not in a test directory (it just looks for the first .git dir it can find). Because we didn't want to properly fix this before, we've been setting the working directory of the test command to the lazygit root, and using the --path CLI arg to override it when the test itself ran. This was a terrible hack. Now, we're passing the lazygit root directory as an env var to the integration test, so that we can set the working directory to the actual path of the test repo; removing the need to use the --path arg.
2024-01-10Add a method GitVersion.IsAtLeastStefan Haller
2024-01-09Add test demonstrating a bug with preserving the commit messageStefan Haller
SplitCommitMessageAndDescription splits at the first '\n\n' that it finds (if there is one), which in this case is between the two paragraphs of the description. This is wrong.
2024-01-09Remove unused functionStefan Haller
I think this is a left-over from before we had the new commit message panel. It no longer makes sense to add a newline to the commit subject.
2023-12-22Add integration test for remote branch sort orderStefan Haller
2023-11-30Add coverage arg for integration testsJesse Duffield
This PR captures the code coverage from our unit and integration tests. At the moment it simply pushes the result to Codacy, a platform that assists with improving code health. Right now the focus is just getting visibility but I want to experiment with alerts on PRs when a PR causes a drop in code coverage. To be clear: I'm not a dogmatist about this: I have no aspirations to get to 100% code coverage, and I don't consider lines-of-code-covered to be a perfect metric, but it is a pretty good heuristic for how extensive your tests are. The good news is that our coverage is actually pretty good which was a surprise to me! As a conflict of interest statement: I'm in Codacy's 'Pioneers' program which provides funding and mentorship, and part of the arrangement is to use Codacy's tooling on lazygit. This is something I'd have been happy to explore even without being part of the program, and just like with any other static analysis tool, we can tweak it to fit our use case and values. ## How we're capturing code coverage This deserves its own section. Basically when you build the lazygit binary you can specify that you want the binary to capture coverage information when it runs. Then, if you run the binary with a GOCOVERDIR env var, it will write coverage information to that directory before exiting. It's a similar story with unit tests except with those you just specify the directory inline via `-test.gocoverdir`. We run both unit tests and integration tests separately in CI, _and_ we run them parallel with different OS's and git versions. So I've got each step uploading the coverage files as an artefact, and then in a separate step we combine all the artefacts together and generate a combined coverage file, which we then upload to codacy (but in future we can do other things with it like warn in a PR if code coverage decreases too much). Another caveat is that when running integration tests, not only do we want to obtain code coverage from code executed by the test binary, we also want to obtain code coverage from code executed by the test runner. Otherwise, for each integration test you add, the setup code (which is run by the test runner, not the test binary) will be considered un-covered and for a large setup step it may appear that your PR _decreases_ coverage on net. Go doesn't easily let you exclude directories from coverage reports so it's better to just track the coverage from both the runner and the binary. The binary expects a GOCOVERDIR env var but the test runner expects a test.gocoverdir positional arg and if you pass the positional arg it will internally overwrite GOCOVERDIR to some random temp directory and if you then pass that to the test binary, it doesn't seem to actually write to it by the time the test finishes. So to get around that we're using LAZYGIT_GOCOVERDIR and then within the test runner we're mapping that to GOCOVERDIR before running the test binary. So they both end up writing to the same directory. Coverage data files are named to avoid conflicts, including something unique to the process, so we don't need to worry about name collisions between the test runner and the test binary's coverage files. We then merge the files together purely for the sake of having fewer artefacts to upload. ## Misc Initially I was able to have all the instances of '/tmp/code_coverage' confined to the ci.yml which was good because it was all in one place but now it's spread across ci.yml and scripts/run_integration_tests.sh and I don't feel great about that but can't think of a way to make it cleaner. I believe there's a use case for running scripts/run_integration_tests.sh outside of CI (so that you can run tests against older git versions locally) so I've made it that unless you pass the LAZYGIT_GOCOVERDIR env var to that script, it skips all the code coverage stuff. On a separate note: it seems that Go's coverage report is based on percentage of statements executed, whereas codacy cares more about lines of code executed, so codacy reports a higher percentage (e.g. 82%) than Go's own coverage report (74%).
2023-11-29Use args struct for RunTestsJesse Duffield
There were too many position arguments
2023-10-16Make the window a little wider for headless integration testsStefan Haller
100 was an unrealistically narrow width; make it a little wider so that we will have to truncate things less often.
2023-09-28Use constant for WAIT_FOR_DEBUGGER env varStefan Haller
2023-09-28Build lazygit without optimizations and inlining when debuggingStefan Haller
This makes the debugging experience better.
2023-09-25Print race detector logs after running a test with -raceStefan Haller
2023-09-25Support -race arg when running integration tests to turn on go's race detectorStefan Haller
For the "cli" and "tui" modes of the test runner there's a "-race" parameter to turn it on; for running tests on CI with go test, you turn it on by setting the environment variable LAZYGIT_RACE_DETECTOR to a non-empty value.
2023-09-15Rename test/results to test/_resultsStefan Haller
This prevents commands like "go test ./..." from looking into it, and it prevents VS Code's Problems panel from showing errors about the go files in that folder.
2023-09-11Provide a simple way to debug an integration testStefan Haller
2023-08-29Add DoesNotContainAnyOf matcherStefan Haller
2023-08-29Add a mechanism to insert non-model items into list contextsStefan Haller
Not used by anything yet.
2023-08-21Add integration testStefan Haller
2023-08-12Add commit graph demoJesse Duffield
2023-08-12Add rebase from marked base commit testJesse Duffield
This also fixes a bug where after the rebase each commit in the commits view had a tick against it because we hadn't refreshed the view since the base commit was no longer marked
2023-08-10Allow deleting remote tags/branches from local tag/branch views (#2738)Federico
2023-08-07Add a Click() primitive to the integration test librarySimon Whitaker
2023-08-07Test bare repos with dotfile setupJesse Duffield
2023-08-04Add custom patch demoJesse Duffield
2023-08-02Add demo for amending old commitJesse Duffield
2023-08-02Appease linterJesse Duffield
2023-08-01Wait in demo after setting captionJesse Duffield
This looks nicer than waiting a second and then showing the caption as the action begins
2023-07-31Add demo test variantJesse Duffield
We're piggybacking on our existing integration test framework to record demos that we can include in our docs
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-30Standardise on using lo for slice functionsJesse Duffield
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-30Add test for opening lazygit in the worktree of a bare repoJesse Duffield
2023-07-30Support fastforwarding worktreeJesse Duffield
2023-07-30Add worktree tests for removing/detachingJesse Duffield
2023-07-30Add worktree integration testsJesse Duffield
2023-07-30Fix testsJesse Duffield
Going and fixing up some submodule tests which were broken by bad assumptions with worktree code
2023-07-30Fix testsJesse Duffield
We now change directories to the repo on startup so we don't need to determine the test path in some special way
2023-07-22Better tag creation UXJesse Duffield
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-22Use fuzzy search when filtering a viewJesse Duffield
This adds fuzzy filtering instead of exact match filtering, which is more forgiving of typos and allows more efficiency.
2023-07-19Add integration test for accordion modeJesse Duffield
2023-07-10Fix Shell.Stash() for older versions of gitStefan Haller
Older versions need an explicit "push" subcommand for the -m option to be recognized.