Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions dot_config/gitswitch/config.json.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"identities": [
{
"id": "personal",
"name": "Your Name",
"email": "personal@example.com"
},
{
"id": "work",
"name": "Your Name",
"email": "work@example.com"
}
],
"bindings": []
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

bindings が空ですが、利用方法の参考となるように、ディレクトリとアイデンティティの紐付け設定のサンプル(例:{"path": "~/work", "identity": "work"})を含めることを検討してください。

}
1 change: 1 addition & 0 deletions dot_config/mise/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ cosign = "2.6.2"
"github:philschmid/mcp-cli" = "0.3.0"
"github:ryo246912/github-markdown-toc.go" = "2.0.1"
"github:ryo246912/lazychezmoi" = "0.0.1"
"github:target-ops/gitswitch" = "1.1.2"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

[settings] セクションで lockfile = true が有効になっていますが、gitswitch の追加に対応する mise.lock の更新がこのプルリクエストに含まれていないようです。環境の再現性を保つため、mise.lock を更新してコミットに含めることを検討してください。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

dot_config/zsh/lazy/mise.zsh において、mise で管理される各ツールの補完設定を個別に記述しているようですが、今回追加された gitswitch に関する設定が見当たりません。シェルの利便性を維持するため、他のツール(ghwt など)と同様に補完の生成・ロード処理を追加することをお勧めします。

"github:trasta298/keifu" = "0.3.0"
"go:github.com/air-verse/air" = "1.65.1"
"go:github.com/atotto/clipboard/cmd/gocopy" = "0.1.4"
Expand Down
74 changes: 74 additions & 0 deletions not_config/memo/gitswitch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# gitswitch 導入・利用ガイド

[gitswitch](https://github.com/target-ops/gitswitch) は、ディレクトリごとに Git のユーザー情報を自動で切り替えるツールです。

## 導入方法

このリポジトリでは `mise` を介して `gitswitch` を導入しています。

1. **ツールのインストール**

```bash
mise install
```

2. **初期化**
既存の設定から ID を自動検出します。
```bash
gitswitch init
```

## 基本的な使い方

### アイデンティティの紐付け

特定のディレクトリ配下で特定のユーザー情報を使うように設定します。

```bash
# ~/work 配下で 'work' アイデンティティを使用
gitswitch use work ~/work

# ~/personal 配下で 'personal' アイデンティティを使用
gitswitch use personal ~/personal
```

### コミットガードの有効化

誤ったユーザー情報でのコミットを防止するために、グローバルなプリコミットフックをインストールします。

```bash
gitswitch guard install
```

### 状態の確認

現在のアイデンティティや各レイヤー(git, ssh, gh, signing)の設定が一致しているか確認します。

```bash
gitswitch doctor
```

## chezmoi との統合に関する注意点

`gitswitch use` を実行すると、`~/.gitconfig` に `includeIf` ブロックが追加されます。

```gitconfig
# >>> gitswitch:work
[includeIf "gitdir:~/work/"]
path = ~/.config/gitswitch/identities/work.gitconfig
# <<< gitswitch:work
```

このリポジトリは `~/.gitconfig` を `dot_config/git/config.tmpl` から管理しています。`gitswitch` によって `~/.gitconfig` に直接加えられた変更は、次に `chezmoi apply` を実行した際に上書きされて消えてしまいます。

### 変更を永続化する方法

`gitswitch` による設定を永続化したい場合は、`~/.gitconfig` に追加された内容を `dot_config/git/config.tmpl` に手動で転記してください。

1. `~/.gitconfig` の内容を確認
2. `dot_config/git/config.tmpl` の末尾などに該当の `includeIf` セクションを追記
3. `chezmoi apply` を実行して反映を確認

## 設定のバックアップ

`dot_config/gitswitch/config.json.sample` を参考に、個人の設定を `~/.config/gitswitch/config.json` に配置することができます。