Skip to content

Commit f922840

Browse files
nullvariantclaude
andauthored
fix: treat empty string as "not set" for optional fields and add SSH docs (#130)
## Changes - Empty strings in optional fields (service, sshKeyPath, sshHost, gpgKeyId) are now treated as "not set" instead of triggering validation errors - Added configSchema.test.ts with 68 comprehensive test cases - Added SSH interaction documentation to README (en, ja): - SSH Key Management Details - Interaction with Existing SSH Config - Why IdentitiesOnly yes? - Updated version to 0.11.1 🖥️ IDE: [Cursor](https://cursor.sh) 🔌 Extension: [Claude Code](https://claude.ai/download) Model-Raw: claude-opus-4-5-20251101 Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 403284b commit f922840

8 files changed

Lines changed: 1189 additions & 3 deletions

File tree

extensions/git-id-switcher/CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.11.1] - 2026-01-12
11+
12+
### Fixed
13+
14+
- **Empty String Validation**
15+
- Empty strings in optional fields (`service`, `sshKeyPath`, `sshHost`, `gpgKeyId`) are now treated as "not set" instead of triggering validation errors
16+
- This eliminates unnecessary warnings when using default settings
17+
- Required fields (`id`, `name`, `email`) still correctly reject empty strings
18+
19+
### Added
20+
21+
- **configSchema Tests**
22+
- Added comprehensive test suite for `configSchema.ts` (68 test cases)
23+
- Covers empty string handling, malicious value rejection, format validation, and edge cases
24+
- Test coverage improved to 92.99%
25+
26+
### Documentation
27+
28+
- **SSH Interaction Sections (en, ja)**
29+
- Added "SSH Key Management Details" section explaining ssh-agent commands
30+
- Added "Interaction with Existing SSH Config" section for compatibility guide
31+
- Added "Why `IdentitiesOnly yes`?" section with recommended configuration
32+
1033
## [0.11.0] - 2026-01-11
1134

1235
### Security

extensions/git-id-switcher/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,54 @@ When you switch identities, the extension does (in order):
408408
Local settings are per-repository, so they don't automatically apply to submodules.
409409
That's why this extension provides submodule propagation (see "Advanced: Submodule Support" for details).
410410

411+
### SSH Key Management Details
412+
413+
Git ID Switcher manages SSH keys through `ssh-agent`:
414+
415+
| Operation | Command |
416+
| ---------- | ------------------------- |
417+
| Add key | `ssh-add <keyPath>` |
418+
| Remove key | `ssh-add -d <keyPath>` |
419+
| List keys | `ssh-add -l` |
420+
421+
**Important:** This extension does **NOT** modify `~/.ssh/config`. You need to set up your SSH config manually (see Step 2 in "Quick Start").
422+
423+
### Interaction with Existing SSH Config
424+
425+
If you already have SSH configuration, Git ID Switcher works alongside it:
426+
427+
| Your Setup | Git ID Switcher Behavior |
428+
| ---------------------------------------- | --------------------------------------------------------------- |
429+
| `~/.ssh/config` with `IdentityFile` | Both can be used; use `IdentitiesOnly yes` to prevent conflicts |
430+
| `GIT_SSH_COMMAND` environment variable | Git uses your custom SSH command; ssh-agent still works |
431+
| `git config core.sshCommand` | Same as above |
432+
| direnv with SSH-related env vars | Works alongside; ssh-agent operates independently |
433+
434+
**Recommended:** Always use `IdentitiesOnly yes` in your SSH config. This prevents SSH from trying multiple keys.
435+
436+
### Why `IdentitiesOnly yes`?
437+
438+
Without this setting, SSH may try keys in this order:
439+
440+
1. Keys loaded in ssh-agent (managed by Git ID Switcher)
441+
2. Keys specified in `~/.ssh/config`
442+
3. Default keys (`~/.ssh/id_rsa`, `~/.ssh/id_ed25519`, etc.)
443+
444+
This can cause authentication failures or unintended key usage.
445+
446+
With `IdentitiesOnly yes`, SSH uses **only the specified key**. This ensures the key you configured in Git ID Switcher is used reliably.
447+
448+
```ssh-config
449+
# Recommended configuration
450+
Host github-work
451+
HostName github.com
452+
User git
453+
IdentityFile ~/.ssh/id_ed25519_work
454+
IdentitiesOnly yes # ← This line is important
455+
```
456+
457+
With this configuration, connections to the `github-work` host will only use `~/.ssh/id_ed25519_work`, and no other keys will be tried.
458+
411459
---
412460

413461
## Advanced: Submodule Support

extensions/git-id-switcher/docs/i18n/en/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,54 @@ When you switch identities, the extension does (in order):
404404
Local settings are per-repository, so they don't automatically apply to submodules.
405405
That's why this extension provides submodule propagation (see "Advanced: Submodule Support" for details).
406406

407+
### SSH Key Management Details
408+
409+
Git ID Switcher manages SSH keys through `ssh-agent`:
410+
411+
| Operation | Command |
412+
| ---------- | ------------------------- |
413+
| Add key | `ssh-add <keyPath>` |
414+
| Remove key | `ssh-add -d <keyPath>` |
415+
| List keys | `ssh-add -l` |
416+
417+
**Important:** This extension does **NOT** modify `~/.ssh/config`. You need to set up your SSH config manually (see Step 2 in "Quick Start").
418+
419+
### Interaction with Existing SSH Config
420+
421+
If you already have SSH configuration, Git ID Switcher works alongside it:
422+
423+
| Your Setup | Git ID Switcher Behavior |
424+
| ---------------------------------------- | --------------------------------------------------------------- |
425+
| `~/.ssh/config` with `IdentityFile` | Both can be used; use `IdentitiesOnly yes` to prevent conflicts |
426+
| `GIT_SSH_COMMAND` environment variable | Git uses your custom SSH command; ssh-agent still works |
427+
| `git config core.sshCommand` | Same as above |
428+
| direnv with SSH-related env vars | Works alongside; ssh-agent operates independently |
429+
430+
**Recommended:** Always use `IdentitiesOnly yes` in your SSH config. This prevents SSH from trying multiple keys.
431+
432+
### Why `IdentitiesOnly yes`?
433+
434+
Without this setting, SSH may try keys in this order:
435+
436+
1. Keys loaded in ssh-agent (managed by Git ID Switcher)
437+
2. Keys specified in `~/.ssh/config`
438+
3. Default keys (`~/.ssh/id_rsa`, `~/.ssh/id_ed25519`, etc.)
439+
440+
This can cause authentication failures or unintended key usage.
441+
442+
With `IdentitiesOnly yes`, SSH uses **only the specified key**. This ensures the key you configured in Git ID Switcher is used reliably.
443+
444+
```ssh-config
445+
# Recommended configuration
446+
Host github-work
447+
HostName github.com
448+
User git
449+
IdentityFile ~/.ssh/id_ed25519_work
450+
IdentitiesOnly yes # ← This line is important
451+
```
452+
453+
With this configuration, connections to the `github-work` host will only use `~/.ssh/id_ed25519_work`, and no other keys will be tried.
454+
407455
---
408456

409457
## Advanced: Submodule Support

extensions/git-id-switcher/docs/i18n/ja/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,54 @@ Gitの設定には3つのレイヤーがあり、下位の設定を上位が上
404404
ローカル設定はリポジトリ単位のため、サブモジュールには自動的に適用されません。
405405
そのため、本拡張機能はサブモジュールへの伝播機能を提供しています(詳細は「上級者向け: サブモジュールサポート」を参照)。
406406

407+
### SSH鍵管理の詳細
408+
409+
Git ID Switcherは`ssh-agent`を通じてSSH鍵を管理します:
410+
411+
| 操作 | 実行コマンド |
412+
| -------- | ------------------------- |
413+
| 鍵を追加 | `ssh-add <keyPath>` |
414+
| 鍵を削除 | `ssh-add -d <keyPath>` |
415+
| 鍵の一覧 | `ssh-add -l` |
416+
417+
**重要:** この拡張機能は `~/.ssh/config`**変更しません**。SSH configの設定は手動で行う必要があります(「クイックスタート」のステップ2を参照)。
418+
419+
### 既存のSSH設定との相互作用
420+
421+
すでにSSH設定がある場合、Git ID Switcherは以下のように動作します:
422+
423+
| あなたの設定 | Git ID Switcherの動作 |
424+
| ---------------------------------------- | ------------------------------------------------------ |
425+
| `~/.ssh/config``IdentityFile` を指定 | 両方が使用可能;`IdentitiesOnly yes` で競合を防止 |
426+
| 環境変数 `GIT_SSH_COMMAND` を設定 | カスタムSSHコマンドを使用;ssh-agentは引き続き動作 |
427+
| `git config core.sshCommand` を設定 | 上記と同様 |
428+
| direnvでSSH関連の環境変数を設定 | 共存可能;ssh-agentは独立して動作 |
429+
430+
**推奨:** SSH configでは常に `IdentitiesOnly yes` を設定してください。これにより、SSHが複数の鍵を試行することを防ぎます。
431+
432+
### なぜ `IdentitiesOnly yes`
433+
434+
この設定がない場合、SSHは以下の順序で鍵を試行する可能性があります:
435+
436+
1. ssh-agentに読み込まれた鍵(Git ID Switcherが管理)
437+
2. `~/.ssh/config` で指定された鍵
438+
3. デフォルトの鍵(`~/.ssh/id_rsa`, `~/.ssh/id_ed25519` など)
439+
440+
これにより、認証失敗や意図しない鍵の使用が発生する可能性があります。
441+
442+
`IdentitiesOnly yes` を設定すると、SSHは**指定された鍵のみ**を使用します。これにより、Git ID Switcherで設定した鍵が確実に使用されます。
443+
444+
```ssh-config
445+
# 推奨される設定
446+
Host github-work
447+
HostName github.com
448+
User git
449+
IdentityFile ~/.ssh/id_ed25519_work
450+
IdentitiesOnly yes # ← この行が重要
451+
```
452+
453+
この設定により、`github-work` ホストへの接続時には `~/.ssh/id_ed25519_work` のみが使用され、他の鍵は試行されません。
454+
407455
---
408456

409457
## 上級者向け: サブモジュールサポート

extensions/git-id-switcher/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/git-id-switcher/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "git-id-switcher",
33
"displayName": "%extension.displayName%",
44
"description": "%extension.description%",
5-
"version": "0.11.0",
5+
"version": "0.11.1",
66
"publisher": "nullvariant",
77
"icon": "images/icon.png",
88
"engines": {

0 commit comments

Comments
 (0)