gitacc-switcher 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. gitacc_switcher-1.0.1/LICENSE +21 -0
  2. gitacc_switcher-1.0.1/MANIFEST.in +5 -0
  3. gitacc_switcher-1.0.1/PKG-INFO +227 -0
  4. gitacc_switcher-1.0.1/README.md +194 -0
  5. gitacc_switcher-1.0.1/gitacc_switcher/__init__.py +4 -0
  6. gitacc_switcher-1.0.1/gitacc_switcher/account_manager.py +421 -0
  7. gitacc_switcher-1.0.1/gitacc_switcher/cli.py +426 -0
  8. gitacc_switcher-1.0.1/gitacc_switcher/completion.py +17 -0
  9. gitacc_switcher-1.0.1/gitacc_switcher/config_manager.py +422 -0
  10. gitacc_switcher-1.0.1/gitacc_switcher/hook_manager.py +230 -0
  11. gitacc_switcher-1.0.1/gitacc_switcher/ssh_manager.py +237 -0
  12. gitacc_switcher-1.0.1/gitacc_switcher/utils.py +82 -0
  13. gitacc_switcher-1.0.1/gitacc_switcher.egg-info/PKG-INFO +227 -0
  14. gitacc_switcher-1.0.1/gitacc_switcher.egg-info/SOURCES.txt +28 -0
  15. gitacc_switcher-1.0.1/gitacc_switcher.egg-info/dependency_links.txt +1 -0
  16. gitacc_switcher-1.0.1/gitacc_switcher.egg-info/entry_points.txt +2 -0
  17. gitacc_switcher-1.0.1/gitacc_switcher.egg-info/requires.txt +1 -0
  18. gitacc_switcher-1.0.1/gitacc_switcher.egg-info/top_level.txt +2 -0
  19. gitacc_switcher-1.0.1/pyproject.toml +48 -0
  20. gitacc_switcher-1.0.1/requirements.txt +3 -0
  21. gitacc_switcher-1.0.1/setup.cfg +4 -0
  22. gitacc_switcher-1.0.1/setup.py +48 -0
  23. gitacc_switcher-1.0.1/tests/__init__.py +1 -0
  24. gitacc_switcher-1.0.1/tests/test_account_manager.py +257 -0
  25. gitacc_switcher-1.0.1/tests/test_cli.py +242 -0
  26. gitacc_switcher-1.0.1/tests/test_completion.py +30 -0
  27. gitacc_switcher-1.0.1/tests/test_config_manager.py +231 -0
  28. gitacc_switcher-1.0.1/tests/test_hook_manager.py +122 -0
  29. gitacc_switcher-1.0.1/tests/test_ssh_manager.py +185 -0
  30. gitacc_switcher-1.0.1/tests/test_utils.py +98 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 KtechHub
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ include LICENSE
2
+ include README.md
3
+ include requirements.txt
4
+ recursive-include tests *.py
5
+
@@ -0,0 +1,227 @@
1
+ Metadata-Version: 2.4
2
+ Name: gitacc-switcher
3
+ Version: 1.0.1
4
+ Summary: Git Account Switcher - Manage multiple Git SSH accounts easily
5
+ Home-page: https://github.com/ktechhub/gitacc-switcher
6
+ Author: ktechhub
7
+ Author-email: ktechhub <mm@ktechhub.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/ktechhub/gitacc-switcher
10
+ Project-URL: Repository, https://github.com/ktechhub/gitacc-switcher
11
+ Project-URL: Issues, https://github.com/ktechhub/gitacc-switcher/issues
12
+ Keywords: git,ssh,account,switcher,multiple,accounts
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.7
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Requires-Python: >=3.7
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: argcomplete>=3.6.3
29
+ Dynamic: author
30
+ Dynamic: home-page
31
+ Dynamic: license-file
32
+ Dynamic: requires-python
33
+
34
+ # Git Account Switcher
35
+
36
+ [![CI](https://github.com/ktechhub/gitacc-switcher/actions/workflows/pipeline.yaml/badge.svg)](https://github.com/ktechhub/gitacc-switcher/actions/workflows/pipeline.yaml)
37
+ [![PyPI](https://img.shields.io/pypi/v/gitacc-switcher)](https://pypi.org/project/gitacc-switcher/)
38
+ [![Python Versions](https://img.shields.io/pypi/pyversions/gitacc-switcher)](https://pypi.org/project/gitacc-switcher/)
39
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
40
+
41
+ A Python CLI tool to easily switch between multiple Git SSH accounts. Manage multiple Git accounts with separate SSH keys and switch between them seamlessly.
42
+
43
+ ## Features
44
+
45
+ - Manage multiple Git accounts with separate SSH keys
46
+ - Switch between accounts easily — one command, no fuss
47
+ - Generate SSH keys automatically (rsa, ed25519, ecdsa, and more)
48
+ - Optional passphrase support for SSH keys
49
+ - Colored terminal output with active account indicator
50
+ - Pre-commit hook to prevent commits with the wrong account
51
+ - Shell autocomplete for bash and zsh
52
+ - Cross-platform support (Linux / macOS)
53
+
54
+ ## Installation
55
+
56
+ ```bash
57
+ pip install gitacc-switcher
58
+ ```
59
+
60
+ ### From source
61
+
62
+ ```bash
63
+ git clone https://github.com/ktechhub/gitacc-switcher.git
64
+ cd gitacc-switcher
65
+ pip install .
66
+ ```
67
+
68
+ ## Quick start
69
+
70
+ ```bash
71
+ # 1. Add your accounts
72
+ gitacc add # prompts for name, email, optional passphrase
73
+ gitacc add --type ed25519 # specify key type
74
+
75
+ # 2. Switch between them
76
+ gitacc switch work # full form
77
+ gitacc work # shorthand — same thing
78
+
79
+ # 3. See what's registered (active account is marked with *)
80
+ gitacc list
81
+
82
+ # 4. Prevent wrong-account commits in a repo
83
+ gitacc init work # sets expected account + installs pre-commit hook
84
+ gitacc verify # manual check
85
+ ```
86
+
87
+ ## Commands
88
+
89
+ ### `gitacc add [--type TYPE]`
90
+
91
+ Add a new Git account. Prompts for:
92
+ - Account identifier (used in key filename and as a reference)
93
+ - Git display name (defaults to account identifier)
94
+ - Email
95
+ - Optional SSH key passphrase
96
+
97
+ Available key types: `rsa` (default), `ed25519`, `ecdsa`, `ecdsa-sk`, `ed25519-sk`, `dsa`
98
+
99
+ ```bash
100
+ gitacc add
101
+ gitacc add --type ed25519
102
+ ```
103
+
104
+ ### `gitacc switch <account>` / `gitacc <account>`
105
+
106
+ Switch to a registered account. Clears all keys from the SSH agent, loads only this account's key, and sets `git config --global user.name/email`.
107
+
108
+ ```bash
109
+ gitacc switch mywork
110
+ gitacc mywork # shorthand
111
+ ```
112
+
113
+ > The SSH agent must already be running (`eval $(ssh-agent)`). If it isn't, gitacc will tell you.
114
+
115
+ ### `gitacc list`
116
+
117
+ List all registered accounts. The currently active account (matching global git config) is marked with `*`.
118
+
119
+ ```bash
120
+ gitacc list
121
+ # Registered accounts:
122
+ # * work → Git name: Jane Doe (jane@company.com) (active)
123
+ # - personal (jane@personal.com)
124
+ ```
125
+
126
+ ### `gitacc remove [account]`
127
+
128
+ Remove an account and its SSH keys. Prompts for confirmation.
129
+
130
+ ```bash
131
+ gitacc remove mywork
132
+ gitacc remove # prompts for account name
133
+ ```
134
+
135
+ ### `gitacc update <account> [--name NAME] [--email EMAIL]`
136
+
137
+ Update the Git display name and/or email for an existing account. Prompts for any field not provided as a flag.
138
+
139
+ ```bash
140
+ gitacc update mywork --name "Jane Doe"
141
+ gitacc update mywork --email "jane@newcompany.com"
142
+ gitacc update mywork # prompts for both
143
+ ```
144
+
145
+ ### `gitacc init <account>`
146
+
147
+ Bind the current repository to an account and install a pre-commit hook. Any commit attempt with a mismatched account will be blocked.
148
+
149
+ ```bash
150
+ cd ~/projects/work-repo
151
+ gitacc init mywork
152
+ ```
153
+
154
+ ### `gitacc verify`
155
+
156
+ Check whether the current Git identity matches the account expected by this repository.
157
+
158
+ ```bash
159
+ gitacc verify
160
+ ```
161
+
162
+ ### `gitacc logout`
163
+
164
+ Kill the SSH agent and unset the global Git user config.
165
+
166
+ ```bash
167
+ gitacc logout
168
+ ```
169
+
170
+ ### `gitacc autocomplete install`
171
+
172
+ Install tab-completion for your shell (bash or zsh). After running, restart your shell or `source` your profile.
173
+
174
+ ```bash
175
+ gitacc autocomplete install
176
+ ```
177
+
178
+ Completions cover: all command names, account names (for `switch`, `remove`, `init`, `update`), and key types (for `add --type`).
179
+
180
+ ### `gitacc --version`
181
+
182
+ ```bash
183
+ gitacc --version
184
+ # gitacc 0.1.0
185
+ ```
186
+
187
+ ## How pre-commit validation works
188
+
189
+ 1. `gitacc init mywork` stores `gitacc.expected-account = mywork` in the repo's local git config and writes a pre-commit hook.
190
+ 2. On every `git commit`, the hook reads `~/.gitacc` and compares the expected account's name/email against the current `git config user.*`.
191
+ 3. If they don't match, the commit is blocked with a helpful message pointing to `gitacc switch`.
192
+
193
+ ## File layout
194
+
195
+ | Path | Purpose |
196
+ |------|---------|
197
+ | `~/.gitacc` | Stores all account entries (INI format) |
198
+ | `~/.ssh/id_<type>_<account>` | Private SSH key per account |
199
+ | `~/.ssh/id_<type>_<account>.pub` | Public SSH key per account |
200
+
201
+ `~/.gitacc` format:
202
+
203
+ ```ini
204
+ [mywork]
205
+ name = Jane Doe
206
+ email = jane@company.com
207
+ private_key = /home/jane/.ssh/id_ed25519_mywork
208
+ public_key = /home/jane/.ssh/id_ed25519_mywork.pub
209
+ ```
210
+
211
+ ## Requirements
212
+
213
+ - Python 3.8+
214
+ - Git
215
+ - SSH tools (`ssh-keygen`, `ssh-agent`, `ssh-add`) in `PATH`
216
+
217
+ ## Changelog
218
+
219
+ See [CHANGELOG.md](CHANGELOG.md) for a full history of changes.
220
+
221
+ ## Contributing
222
+
223
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions, commit conventions, and the PR process.
224
+
225
+ ## License
226
+
227
+ MIT — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,194 @@
1
+ # Git Account Switcher
2
+
3
+ [![CI](https://github.com/ktechhub/gitacc-switcher/actions/workflows/pipeline.yaml/badge.svg)](https://github.com/ktechhub/gitacc-switcher/actions/workflows/pipeline.yaml)
4
+ [![PyPI](https://img.shields.io/pypi/v/gitacc-switcher)](https://pypi.org/project/gitacc-switcher/)
5
+ [![Python Versions](https://img.shields.io/pypi/pyversions/gitacc-switcher)](https://pypi.org/project/gitacc-switcher/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
+
8
+ A Python CLI tool to easily switch between multiple Git SSH accounts. Manage multiple Git accounts with separate SSH keys and switch between them seamlessly.
9
+
10
+ ## Features
11
+
12
+ - Manage multiple Git accounts with separate SSH keys
13
+ - Switch between accounts easily — one command, no fuss
14
+ - Generate SSH keys automatically (rsa, ed25519, ecdsa, and more)
15
+ - Optional passphrase support for SSH keys
16
+ - Colored terminal output with active account indicator
17
+ - Pre-commit hook to prevent commits with the wrong account
18
+ - Shell autocomplete for bash and zsh
19
+ - Cross-platform support (Linux / macOS)
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ pip install gitacc-switcher
25
+ ```
26
+
27
+ ### From source
28
+
29
+ ```bash
30
+ git clone https://github.com/ktechhub/gitacc-switcher.git
31
+ cd gitacc-switcher
32
+ pip install .
33
+ ```
34
+
35
+ ## Quick start
36
+
37
+ ```bash
38
+ # 1. Add your accounts
39
+ gitacc add # prompts for name, email, optional passphrase
40
+ gitacc add --type ed25519 # specify key type
41
+
42
+ # 2. Switch between them
43
+ gitacc switch work # full form
44
+ gitacc work # shorthand — same thing
45
+
46
+ # 3. See what's registered (active account is marked with *)
47
+ gitacc list
48
+
49
+ # 4. Prevent wrong-account commits in a repo
50
+ gitacc init work # sets expected account + installs pre-commit hook
51
+ gitacc verify # manual check
52
+ ```
53
+
54
+ ## Commands
55
+
56
+ ### `gitacc add [--type TYPE]`
57
+
58
+ Add a new Git account. Prompts for:
59
+ - Account identifier (used in key filename and as a reference)
60
+ - Git display name (defaults to account identifier)
61
+ - Email
62
+ - Optional SSH key passphrase
63
+
64
+ Available key types: `rsa` (default), `ed25519`, `ecdsa`, `ecdsa-sk`, `ed25519-sk`, `dsa`
65
+
66
+ ```bash
67
+ gitacc add
68
+ gitacc add --type ed25519
69
+ ```
70
+
71
+ ### `gitacc switch <account>` / `gitacc <account>`
72
+
73
+ Switch to a registered account. Clears all keys from the SSH agent, loads only this account's key, and sets `git config --global user.name/email`.
74
+
75
+ ```bash
76
+ gitacc switch mywork
77
+ gitacc mywork # shorthand
78
+ ```
79
+
80
+ > The SSH agent must already be running (`eval $(ssh-agent)`). If it isn't, gitacc will tell you.
81
+
82
+ ### `gitacc list`
83
+
84
+ List all registered accounts. The currently active account (matching global git config) is marked with `*`.
85
+
86
+ ```bash
87
+ gitacc list
88
+ # Registered accounts:
89
+ # * work → Git name: Jane Doe (jane@company.com) (active)
90
+ # - personal (jane@personal.com)
91
+ ```
92
+
93
+ ### `gitacc remove [account]`
94
+
95
+ Remove an account and its SSH keys. Prompts for confirmation.
96
+
97
+ ```bash
98
+ gitacc remove mywork
99
+ gitacc remove # prompts for account name
100
+ ```
101
+
102
+ ### `gitacc update <account> [--name NAME] [--email EMAIL]`
103
+
104
+ Update the Git display name and/or email for an existing account. Prompts for any field not provided as a flag.
105
+
106
+ ```bash
107
+ gitacc update mywork --name "Jane Doe"
108
+ gitacc update mywork --email "jane@newcompany.com"
109
+ gitacc update mywork # prompts for both
110
+ ```
111
+
112
+ ### `gitacc init <account>`
113
+
114
+ Bind the current repository to an account and install a pre-commit hook. Any commit attempt with a mismatched account will be blocked.
115
+
116
+ ```bash
117
+ cd ~/projects/work-repo
118
+ gitacc init mywork
119
+ ```
120
+
121
+ ### `gitacc verify`
122
+
123
+ Check whether the current Git identity matches the account expected by this repository.
124
+
125
+ ```bash
126
+ gitacc verify
127
+ ```
128
+
129
+ ### `gitacc logout`
130
+
131
+ Kill the SSH agent and unset the global Git user config.
132
+
133
+ ```bash
134
+ gitacc logout
135
+ ```
136
+
137
+ ### `gitacc autocomplete install`
138
+
139
+ Install tab-completion for your shell (bash or zsh). After running, restart your shell or `source` your profile.
140
+
141
+ ```bash
142
+ gitacc autocomplete install
143
+ ```
144
+
145
+ Completions cover: all command names, account names (for `switch`, `remove`, `init`, `update`), and key types (for `add --type`).
146
+
147
+ ### `gitacc --version`
148
+
149
+ ```bash
150
+ gitacc --version
151
+ # gitacc 0.1.0
152
+ ```
153
+
154
+ ## How pre-commit validation works
155
+
156
+ 1. `gitacc init mywork` stores `gitacc.expected-account = mywork` in the repo's local git config and writes a pre-commit hook.
157
+ 2. On every `git commit`, the hook reads `~/.gitacc` and compares the expected account's name/email against the current `git config user.*`.
158
+ 3. If they don't match, the commit is blocked with a helpful message pointing to `gitacc switch`.
159
+
160
+ ## File layout
161
+
162
+ | Path | Purpose |
163
+ |------|---------|
164
+ | `~/.gitacc` | Stores all account entries (INI format) |
165
+ | `~/.ssh/id_<type>_<account>` | Private SSH key per account |
166
+ | `~/.ssh/id_<type>_<account>.pub` | Public SSH key per account |
167
+
168
+ `~/.gitacc` format:
169
+
170
+ ```ini
171
+ [mywork]
172
+ name = Jane Doe
173
+ email = jane@company.com
174
+ private_key = /home/jane/.ssh/id_ed25519_mywork
175
+ public_key = /home/jane/.ssh/id_ed25519_mywork.pub
176
+ ```
177
+
178
+ ## Requirements
179
+
180
+ - Python 3.8+
181
+ - Git
182
+ - SSH tools (`ssh-keygen`, `ssh-agent`, `ssh-add`) in `PATH`
183
+
184
+ ## Changelog
185
+
186
+ See [CHANGELOG.md](CHANGELOG.md) for a full history of changes.
187
+
188
+ ## Contributing
189
+
190
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions, commit conventions, and the PR process.
191
+
192
+ ## License
193
+
194
+ MIT — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,4 @@
1
+ """Git Account Switcher - Manage multiple Git SSH accounts easily."""
2
+
3
+ __version__ = "1.0.1"
4
+ __author__ = "ktechhub"