Repository navigation
Conversation
Contributor
|
Thanks for your pull request! Unfortunately, it doesn't meet the requirements for review:
Please update your PR to address the above. This PR will be automatically closed in 7 days if these requirements are not met. Full contribution requirements
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change to preserve Windows PATHEXT for hook shells.
No open issues 🎉
What changed in this PR
This PR addresses #23245 and #23154 by preserving Windows PATHEXT when GitHub Desktop loads the hook shell environment, allowing PowerShell hooks to resolve executables and command shims correctly.
Changes:
- Seeds Windows shell launches with the parent’s
PATHEXT, using case-insensitive lookup and a default extension list when missing or empty. - Leaves non-Windows behavior unchanged and allows shell profiles to customize the seeded value.
- Adds Windows assertions for
.EXEand.CMDacross supported shells, plus a missing-parent fallback test.
| File | Description |
|---|---|
app/test/unit/get-shell-env-test.ts |
Adds Windows PATHEXT assertions and PowerShell fallback coverage. |
app/src/lib/hooks/get-shell-env.ts |
Seeds PATHEXT before spawning Windows hook shells. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #23245
Closes #23154
Description
getShellEnvpreviously spawned the configured hook shell withenv: {}. Because Node/libuv does not injectPATHEXTinto an empty environment object, PowerShell (both Windows PowerShell 5.1 and PowerShell 7) initializedPATHEXTto.CPLalone, breaking extensionless lookup for tools likegit(e.g.,git-lfs pre-push) and.cmdshims (npm/ts-node) inside Git hooks.app/src/lib/hooks/get-shell-env.tsto seedPATHEXTfromprocess.env(looked up case-insensitively, falling back to.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSCif unset) when spawning the shell on Windows (__WIN32__). Non-Windows platforms continue passing{}.PATHEXTbefore spawning rather than patching afterward lets user PowerShell$PROFILEscripts extend or override$env:PATHEXTnormally instead of starting from.CPL.app/test/unit/get-shell-env-test.tsverifyingPATHEXTincludes.EXEand.CMDacrossgit-bash,pwsh,powershell, andcmd, plus fallback behavior when parentPATHEXTis absent.How I verified
PATHEXT=.CPLdirectly on Windows 11 withpowershell.exeandpwsh.exewhen spawned withenv: {}.node script/test.mjs app/test/unit/get-shell-env-test.tspasses (5/5tests acrossgit-bash,pwsh,powershell,cmd, and missing-PATHEXTfallback).npm run prettier,npm run lint:src,npx tsc --noEmit, andnpm run test:eslint(6/6) pass with zero warnings or errors.Screenshots
N/A (no UI changes)
Release notes
Notes: [Fixed] Git hooks using PowerShell on Windows now preserve
PATHEXTso Git LFS and command shims resolve correctly - #23245