Skip to content

Commit 8cbf531

Browse files
committed
Use * activation to augment PATH before git extension's async operations
1 parent a78545c commit 8cbf531

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ test/
2828

2929
## Key Design Decisions
3030

31-
- **Eager registration:** Decoration provider is registered before repo scanning completes. The git extension may not have discovered repositories when we activate (`onStartupFinished`), so gating on repo state causes missed decorations.
31+
- **`*` activation:** The extension uses `*` activation (not `onStartupFinished`) so PATH is augmented before the git extension's async repo discovery runs git operations that trigger clean/smudge filters. Combined with `extensionDependencies` on `vscode.git`, the sequence is: git extension activates and schedules async work, our extension activates immediately after and sets PATH synchronously, then the git extension's async operations find git-crypt. The `package` and `publish` scripts pass `--allow-star-activation` to suppress the vsce warning -- this is intentional since our activation is lightweight (just PATH augmentation).
32+
- **Eager registration:** Decoration provider is registered before repo scanning completes. The git extension may not have discovered repositories when we activate, so gating on repo state causes missed decorations.
3233
- **PATH augmentation:** The VSCode extension host has a minimal PATH. `src/extension.ts` appends `/opt/homebrew/bin`, `/usr/local/bin`, `/usr/bin`, and the bundled `bin/` directory to `process.env.PATH` on the shared extension host so `git-crypt` is discoverable by all extensions (including the built-in git extension's clean/smudge filter invocations). User-installed git-crypt takes precedence; the bundled binary is appended last. This is the extension's primary function.
3334
- **Bundled binary:** Platform-specific VSIX files ship a statically linked git-crypt binary (macOS arm64, Linux x64/arm64). A universal VSIX (no binary) is also published for unsupported platforms. The binary version is pinned in `git-crypt-version.txt` with a sha256 checksum.
3435
- **Unlock detection via key directory:** `isRepoUnlocked()` checks for `.git/git-crypt/keys/` existence rather than parsing `git-crypt status` output (which is slow on large repos and ambiguous -- it labels managed files as "encrypted:" even when unlocked).

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ src/
3737
git.ts # Low-level git/git-crypt command helpers (execFile, no shell)
3838
```
3939

40-
The extension activates lazily (`onStartupFinished`), augments the extension host's `process.env.PATH` so `git-crypt` is discoverable, checks for `git-crypt` availability, scans workspace repositories for git-crypt files via `git check-attr`, and registers a file decoration provider. All git interaction uses `execFile` with array arguments (no shell) to prevent command injection.
40+
The extension uses `*` activation so it can augment `process.env.PATH` before the git extension's async repo discovery triggers clean/smudge filters. `extensionDependencies` on `vscode.git` ensures our activation runs right after the git extension's, and our PATH augmentation is synchronous so it completes before any async git operations execute. The `package` and `publish` npm scripts pass `--allow-star-activation` to vsce to acknowledge this is intentional (our activation is lightweight). After PATH setup, the extension checks for `git-crypt` availability, scans workspace repositories for git-crypt files via `git check-attr`, and registers a file decoration provider. All git interaction uses `execFile` with array arguments (no shell) to prevent command injection.
4141

4242
## Release Workflow
4343

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"Other"
2222
],
2323
"activationEvents": [
24-
"onStartupFinished"
24+
"*"
2525
],
2626
"extensionDependencies": [
2727
"vscode.git"
@@ -43,8 +43,8 @@
4343
"build": "node esbuild.js",
4444
"watch": "node esbuild.js --watch",
4545
"test": "node --import tsx --test test/*.test.ts",
46-
"package": "vsce package",
47-
"publish": "vsce publish",
46+
"package": "vsce package --allow-star-activation",
47+
"publish": "vsce publish --allow-star-activation",
4848
"reinstall": "rm -f *.vsix && npm run package && code --install-extension git-crypt-vscode-*.vsix"
4949
},
5050
"devDependencies": {

0 commit comments

Comments
 (0)