polygit 0.3.2__tar.gz → 0.3.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polygit
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Manage multiple git repos from a single .pgit config file.
5
5
  Project-URL: Repository, https://gitlab.com/gary.schaetz/public/polygit
6
6
  Author-email: Gary Schaetz <gary@schaetzkc.com>
@@ -36,7 +36,7 @@ Description-Content-Type: text/markdown
36
36
  Manage multiple git repos from a single `.pgit` config file.
37
37
 
38
38
  ```bash
39
- pip install polygit
39
+ uv tool install polygit
40
40
  ```
41
41
 
42
42
  ## Usage
@@ -3,7 +3,7 @@
3
3
  Manage multiple git repos from a single `.pgit` config file.
4
4
 
5
5
  ```bash
6
- pip install polygit
6
+ uv tool install polygit
7
7
  ```
8
8
 
9
9
  ## Usage
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "polygit"
7
- version = "0.3.2"
7
+ version = "0.3.3"
8
8
  description = "Manage multiple git repos from a single .pgit config file."
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE.txt" }
@@ -40,28 +40,24 @@ def del_nested(d, keys):
40
40
 
41
41
 
42
42
  def _add_to_config(config, fs_platform, local_path, remote_url):
43
- """Insert a repo entry into the config data structure."""
43
+ """Insert a repo entry into the config data structure.
44
+
45
+ Always nests under the *local* namespace (the repo's actual directory
46
+ location), with a `{remote: ...}` override when the remote path differs
47
+ — e.g. a repo cloned under a local namespace unrelated to its remote
48
+ org/namespace.
49
+ """
44
50
  local_parts = local_path.split("/")
45
51
  local_name = local_parts[-1]
52
+ local_ns = "/".join(local_parts[:-1])
46
53
  _, remote_path = parse_remote_url(remote_url)
47
54
  platform_data = config.setdefault(fs_platform, {})
55
+ ns_data = platform_data.setdefault(local_ns, {})
48
56
 
49
- if remote_path:
50
- r_parts = remote_path.split("/")
51
- r_name = r_parts[-1]
52
- r_ns = "/".join(r_parts[:-1])
53
- ns_data = platform_data.setdefault(r_ns, {})
54
- if local_path == f"{r_ns}/{r_name}":
55
- ns_data[r_name] = None
56
- else:
57
- sub = local_path[len(r_ns)+1:] if local_path.startswith(r_ns + "/") else local_name
58
- node = ns_data
59
- for part in sub.split("/")[:-1]:
60
- node = node.setdefault(part, {})
61
- node[sub.split("/")[-1]] = {"remote": remote_path}
57
+ if remote_path and remote_path != local_path:
58
+ ns_data[local_name] = {"remote": remote_path}
62
59
  else:
63
- local_ns = "/".join(local_parts[:-1])
64
- platform_data.setdefault(local_ns, {})[local_name] = None
60
+ ns_data[local_name] = None
65
61
 
66
62
 
67
63
  def cmd_repos(config, base, config_path):
@@ -2,7 +2,7 @@ import tempfile
2
2
  import pytest
3
3
  from pathlib import Path
4
4
  from polygit.config import find_config, load_config, write_config
5
- from polygit.repos import parse_remote_url, del_nested
5
+ from polygit.repos import parse_remote_url, del_nested, _add_to_config
6
6
  from polygit.repo import walk
7
7
 
8
8
 
@@ -59,6 +59,26 @@ def test_del_nested_preserves_siblings():
59
59
  assert d == {"a": {"c": None}}
60
60
 
61
61
 
62
+ # ── _add_to_config ──────────────────────────────────────────────────────────
63
+
64
+ def test_add_to_config_plain():
65
+ config = {}
66
+ _add_to_config(config, "github", "gschaetz/mousehat", "git@github.com:gschaetz/mousehat.git")
67
+ assert config == {"github": {"gschaetz": {"mousehat": None}}}
68
+
69
+ def test_add_to_config_cross_namespace_override():
70
+ # Local dir lives under a namespace unrelated to the remote org — must
71
+ # nest under the local namespace, not silently fall back to the remote's.
72
+ config = {}
73
+ _add_to_config(config, "github", "community/modelrelay", "git@github.com:ellipticmarketing/modelrelay.git")
74
+ assert config == {"github": {"community": {"modelrelay": {"remote": "ellipticmarketing/modelrelay"}}}}
75
+
76
+ def test_add_to_config_no_remote():
77
+ config = {}
78
+ _add_to_config(config, "github", "gschaetz/scratch", None)
79
+ assert config == {"github": {"gschaetz": {"scratch": None}}}
80
+
81
+
62
82
  # ── find_config / write_config / load_config ──────────────────────────────────
63
83
 
64
84
  def test_find_config_in_cwd():
@@ -90,7 +90,7 @@ wheels = [
90
90
 
91
91
  [[package]]
92
92
  name = "polygit"
93
- version = "0.3.2"
93
+ version = "0.3.3"
94
94
  source = { editable = "." }
95
95
  dependencies = [
96
96
  { name = "pyyaml" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes