[codex] fix simple-git unsafe env handling
Merged
KI
6mo ago+390+390+012345678901234567890123456789-36-36-01234567890123456789
What changed
- Replaces the shell-env
PAGER/GIT_PAGERstripping workaround with a simple-git configuration that explicitly allows the user's Git environment/config hooks. - Centralizes the simple-git unsafe allow-list in
@superset/shared/simple-git-optionsso desktop and host-service use the same policy. - Routes host-service production simple-git construction through one wrapper and adds a lint guard to prevent future direct production
simpleGit(...)usage outside approved wrappers. - Adds regression coverage proving default simple-git rejects the blocked env while our configured client accepts it.
Why
The allowUnsafeEditor / allowUnsafePager failures are thrown by simple-git@3.36.0, not by Git itself. Superset is a local Git client, so honoring the user's local Git environment is expected. Deleting individual env vars treated one symptom and changed user Git semantics.
Validation
bun test packages/shared/src/simple-git-options.test.ts apps/desktop/src/lib/trpc/routers/workspaces/utils/git-client.test.ts packages/host-service/src/runtime/git/simple-git.test.ts apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.test.tsbun run lintbun run typecheckinpackages/sharedbun run typecheckinpackages/host-servicebun run typecheckinapps/desktop- Mutation-checked the regression tests by temporarily removing
allowUnsafeEditorandallowUnsafeAlias; both cases failed as expected before restoration.
Summary by cubic
Fixes simple-git unsafe env errors by allowing user Git env/config and centralizing options to honor local Git behavior. Removes the PAGER stripping workaround and routes production Git usage through approved wrappers.
-
Bug Fixes
- Enable all
simple-git@3.36unsafe flags via@superset/shared/simple-git-optionsso editor/pager/hooks work as expected. - Preserve
PAGER/GIT_PAGERin desktop shell env. - Add tests covering the explicit unsafe flag list and acceptance of user env vs default rejection.
- Enable all
-
Refactors
- Add
createUserSimpleGitwrapper (host-service) and use shared options in desktop and host-service. - Replace direct
simple-gitusage with wrappers in production paths. - Add
scripts/check-simple-git-usage.shand run it inscripts/lint.shto forbid direct imports/constructors outside tests and approved wrappers.
- Add
Summary by CodeRabbit
-
New Features
- Improved Git integration with centralized configuration for safer, more reliable Git operations across the application.
- Enhanced environment variable preservation for Git-related settings (editor, pager configurations).
-
Bug Fixes
- Resolved issues with Git hook handling by implementing consistent Git client initialization.
-
Tests
- Added comprehensive test coverage for Git client configuration and environment variable handling.