Skip to content

Commit d715890

Browse files
committed
src/cli(fix[workspace-label]): re-home ./ sections
why: Path-first adds from inside a workspace still wrote './' sections even after adopting tilde labels. what: - compute a preferred workspace label and migrate existing './' entries to the tilde label, keeping config_items in sync
1 parent de203a4 commit d715890

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/vcspull/cli/add.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,17 +487,28 @@ def _aggregate_items(items: list[tuple[str, t.Any]]) -> dict[str, t.Any]:
487487
else:
488488
preserve_workspace_label = workspace_root_path in {".", "./"}
489489

490+
preferred_label = workspace_root_label(
491+
workspace_path,
492+
cwd=cwd,
493+
home=home,
494+
preserve_cwd_label=preserve_workspace_label,
495+
)
496+
490497
if workspace_label is None:
491-
workspace_label = workspace_root_label(
492-
workspace_path,
493-
cwd=cwd,
494-
home=home,
495-
preserve_cwd_label=preserve_workspace_label,
496-
)
498+
workspace_label = preferred_label
497499
workspace_map[workspace_path] = workspace_label
498500
raw_config.setdefault(workspace_label, {})
499501
if not merge_duplicates:
500502
config_items.append((workspace_label, {}))
503+
elif workspace_label == "./" and preferred_label != workspace_label:
504+
existing_section = raw_config.pop(workspace_label, {})
505+
raw_config[preferred_label] = existing_section
506+
workspace_map[workspace_path] = preferred_label
507+
workspace_label = preferred_label
508+
if not merge_duplicates:
509+
for idx, (label, section) in enumerate(config_items):
510+
if label == "./":
511+
config_items[idx] = (preferred_label, section)
501512

502513
if workspace_label not in raw_config:
503514
raw_config[workspace_label] = {}

0 commit comments

Comments
 (0)