gitacc-switcher 1.2.0__tar.gz → 1.2.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.2.0/gitacc_switcher.egg-info → gitacc_switcher-1.2.1}/PKG-INFO +1 -1
  2. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/gitacc_switcher/__init__.py +1 -1
  3. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/gitacc_switcher/config_manager.py +15 -0
  4. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1/gitacc_switcher.egg-info}/PKG-INFO +1 -1
  5. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/pyproject.toml +1 -1
  6. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/setup.py +1 -1
  7. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/tests/test_config_manager.py +21 -0
  8. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/LICENSE +0 -0
  9. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/MANIFEST.in +0 -0
  10. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/README.md +0 -0
  11. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/gitacc_switcher/account_manager.py +0 -0
  12. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/gitacc_switcher/cli.py +0 -0
  13. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/gitacc_switcher/completion.py +0 -0
  14. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/gitacc_switcher/hook_manager.py +0 -0
  15. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/gitacc_switcher/ssh_manager.py +0 -0
  16. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/gitacc_switcher/utils.py +0 -0
  17. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/gitacc_switcher.egg-info/SOURCES.txt +0 -0
  18. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/gitacc_switcher.egg-info/dependency_links.txt +0 -0
  19. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/gitacc_switcher.egg-info/entry_points.txt +0 -0
  20. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/gitacc_switcher.egg-info/requires.txt +0 -0
  21. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/gitacc_switcher.egg-info/top_level.txt +0 -0
  22. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/requirements.txt +0 -0
  23. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/setup.cfg +0 -0
  24. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/tests/__init__.py +0 -0
  25. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/tests/test_account_manager.py +0 -0
  26. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/tests/test_cli.py +0 -0
  27. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/tests/test_completion.py +0 -0
  28. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/tests/test_hook_manager.py +0 -0
  29. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/tests/test_ssh_manager.py +0 -0
  30. {gitacc_switcher-1.2.0 → gitacc_switcher-1.2.1}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitacc-switcher
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: Git Account Switcher - Manage multiple Git SSH accounts easily
5
5
  Home-page: https://github.com/ktechhub/gitacc_switcher
6
6
  Author: ktechhub
@@ -1,4 +1,4 @@
1
1
  """Git Account Switcher - Manage multiple Git SSH accounts easily."""
2
2
 
3
- __version__ = "1.2.0"
3
+ __version__ = "1.2.1"
4
4
  __author__ = "ktechhub"
@@ -359,22 +359,37 @@ class ConfigManager:
359
359
  line = lines[i]
360
360
  if re.match(rf"^\s*\[{re.escape(account_name)}\]\s*$", line):
361
361
  in_target_section = True
362
+ field_written = False
362
363
  new_lines.append(line)
363
364
  i += 1
364
365
  while i < len(lines) and in_target_section:
365
366
  if re.match(r"^\s*\[", lines[i]) and not re.match(
366
367
  rf"^\s*\[{re.escape(account_name)}\]\s*$", lines[i]
367
368
  ):
369
+ if not field_written:
370
+ # Field never appeared in this section (e.g. an
371
+ # account written before this field existed) —
372
+ # add it rather than silently leaving it unset.
373
+ new_lines.append(f"\t{field} = {new_value}\n")
374
+ field_written = True
368
375
  in_target_section = False
369
376
  new_lines.append(lines[i])
370
377
  i += 1
371
378
  break
372
379
  elif re.match(rf"^\s*{re.escape(field)}\s*=", lines[i]):
373
380
  new_lines.append(f"\t{field} = {new_value}\n")
381
+ field_written = True
374
382
  i += 1
375
383
  else:
376
384
  new_lines.append(lines[i])
377
385
  i += 1
386
+ else:
387
+ # Loop ended because we reached end of file, not a break —
388
+ # the target section is the last one, so append here too.
389
+ if in_target_section and not field_written:
390
+ new_lines.append(f"\t{field} = {new_value}\n")
391
+ field_written = True
392
+ in_target_section = False
378
393
  else:
379
394
  new_lines.append(line)
380
395
  i += 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitacc-switcher
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: Git Account Switcher - Manage multiple Git SSH accounts easily
5
5
  Home-page: https://github.com/ktechhub/gitacc_switcher
6
6
  Author: ktechhub
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gitacc-switcher"
7
- version = "1.2.0"
7
+ version = "1.2.1"
8
8
  description = "Git Account Switcher - Manage multiple Git SSH accounts easily"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
@@ -9,7 +9,7 @@ long_description = readme_file.read_text() if readme_file.exists() else ""
9
9
 
10
10
  setup(
11
11
  name="gitacc-switcher",
12
- version="1.2.0",
12
+ version="1.2.1",
13
13
  description="Git Account Switcher - Manage multiple Git SSH accounts easily",
14
14
  long_description=long_description,
15
15
  long_description_content_type="text/markdown",
@@ -164,6 +164,27 @@ class TestUpdateAccountField:
164
164
  def test_returns_false_for_missing_account(self, config_with_accounts):
165
165
  assert config_with_accounts.update_account_field("nobody", "name", "X") is False
166
166
 
167
+ def test_appends_field_missing_from_section(self, config_with_accounts):
168
+ # SAMPLE_GITACC accounts have no "sign" field — this reproduces a pre-1.2.0
169
+ # account whose section was written before that field existed.
170
+ assert "sign" not in config_with_accounts.get_account("work")
171
+ assert config_with_accounts.update_account_field("work", "sign", "true") is True
172
+ assert config_with_accounts.get_account("work")["sign"] == "true"
173
+
174
+ def test_appending_missing_field_preserves_other_fields(self, config_with_accounts):
175
+ config_with_accounts.update_account_field("work", "sign", "true")
176
+ account = config_with_accounts.get_account("work")
177
+ assert account["name"] == "Work User"
178
+ assert account["email"] == "work@company.com"
179
+ assert account["private_key"] == "/home/user/.ssh/id_rsa_work"
180
+ assert account["public_key"] == "/home/user/.ssh/id_rsa_work.pub"
181
+
182
+ def test_appending_missing_field_does_not_affect_other_account(
183
+ self, config_with_accounts
184
+ ):
185
+ config_with_accounts.update_account_field("work", "sign", "true")
186
+ assert "sign" not in config_with_accounts.get_account("personal")
187
+
167
188
 
168
189
  class TestListAccountNames:
169
190
  def test_empty(self, config):
File without changes