jesseduffield.lazygit/pkg/integration/tests
Stefan Haller bb8955f2de Load direnv environment when switching repos
When a user opens a repo from the recent-repos menu or jumps between
worktrees inside lazygit, only the env vars present at process startup
reach subprocesses. That breaks pre-commit hooks and other tools whose
dependencies are pulled in by a per-repo .envrc — users were left with
read-only operations because the env their shell would normally load via
direnv never made it into lazygit's git invocations.

Shell out to `direnv export json` after each chdir and apply the JSON
delta via os.Setenv/Unsetenv. direnv tracks the previous load in its own
DIRENV_DIFF env var, so the delta also unloads vars from the old repo
when entering one without a matching .envrc. If direnv isn't on PATH the
call is a no-op, so users who don't use direnv pay nothing and users who
do need no config to opt in. Any stderr direnv emits (loading messages,
"blocked .envrc" errors, etc.) goes to the command log.

The integration test puts a fake direnv on PATH and asserts that a value
it exports reaches a custom command after switching repos. Wiring this
up needed runner.go to support `{{actualPath}}` placeholders in
ExtraEnvVars, mirroring the existing support for ExtraCmdArgs, so the
test can prepend a fixture-relative directory to PATH.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 09:05:01 +02:00
..
bisect Un-deprecate UserConfig.Git.Log.Order and ShowGraph 2025-07-09 13:15:03 +02:00
branch Use more widely-supported Unicode symbols for the commit graph 2026-05-04 13:06:29 +02:00
cherry_pick Clear cherry-pick buffer when copying after a paste 2026-05-09 14:02:42 +02:00
commit Convert keybinding fields to Keybinding 2026-05-25 15:32:47 +02:00
config Convert custom command Key fields to Keybinding 2026-05-25 15:32:47 +02:00
conflicts Add merge options menu 2025-10-09 08:45:58 +02:00
custom_commands Convert custom command Key fields to Keybinding 2026-05-25 15:32:47 +02:00
demo Convert custom command Key fields to Keybinding 2026-05-25 15:32:47 +02:00
diff Fix copying a file's absolute path when running in a linked worktree 2026-04-19 11:16:02 +02:00
file Fix copying a file's absolute path when running in a linked worktree 2026-04-19 11:16:02 +02:00
filter_and_search Convert keybinding fields to Keybinding 2026-05-25 15:32:47 +02:00
filter_by_author Un-deprecate UserConfig.Git.Log.Order and ShowGraph 2025-07-09 13:15:03 +02:00
filter_by_path When entering a commit in path filtering mode, select the filtered path 2025-10-09 09:58:15 +02:00
interactive_rebase Convert custom command Key fields to Keybinding 2026-05-25 15:32:47 +02:00
misc Load direnv environment when switching repos 2026-06-04 09:05:01 +02:00
patch_building Filter file views rather than search 2026-03-07 20:04:31 +01:00
reflog Un-deprecate UserConfig.Git.Log.Order and ShowGraph 2025-07-09 13:15:03 +02:00
remote feat: add fork remote command 2025-11-16 17:26:00 +01:00
shared Add merge options menu 2025-10-09 08:45:58 +02:00
shell_commands Rename "Custom Command" to "Shell Command" 2024-08-17 10:56:03 +02:00
staging Revert test workaround 2026-03-19 16:57:53 +01:00
stash Fix dropping a range of stashes in filtered mode 2025-08-25 18:41:06 +02:00
status Add backward cycling support for all branches log view 2026-03-08 17:06:17 +01:00
submodule Convert custom command Key fields to Keybinding 2026-05-25 15:32:47 +02:00
sync Refresh worktrees before auto-forwarding branches 2026-05-21 13:59:18 +02:00
tag Fix deleting a remote tag when a remote branch with the same name exists 2025-11-27 19:52:18 +01:00
ui Fix crash when keybindings are disabled that we want to show in the status bar 2026-05-28 19:26:43 +02:00
undo Switch to branches view when checking out a commit 2025-11-16 21:23:40 +01:00
worktree Convert custom command Key fields to Keybinding 2026-05-25 15:32:47 +02:00
test_list.go Load direnv environment when switching repos 2026-06-04 09:05:01 +02:00
test_list_generator.go Fix typos 2025-01-03 10:50:36 +11:00
tests.go Set working directory in lazygit test command 2024-01-12 19:59:31 +11:00