Skip to content

Commit 4015dc3

Browse files
committed
src/cli(fix[workspace-label]): tilde workspace for path-first add
why: Running vcspull add from the workspace root should still display the tilde path instead of './'. what: - allow workspace_root_label callers to opt out of the cwd short-circuit - pass preserve_cwd_label only when users explicitly request './' or for legacy name/url flows
1 parent 3aa294d commit 4015dc3

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/vcspull/cli/add.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,10 @@ def handle_add_command(args: argparse.Namespace) -> None:
201201
repo_path,
202202
)
203203

204+
workspace_root_arg = getattr(args, "workspace_root_path", None)
204205
workspace_root_input = (
205-
args.workspace_root_path
206-
if getattr(args, "workspace_root_path", None)
206+
workspace_root_arg
207+
if workspace_root_arg is not None
207208
else repo_path.parent.as_posix()
208209
)
209210

@@ -212,6 +213,7 @@ def handle_add_command(args: argparse.Namespace) -> None:
212213
workspace_path,
213214
cwd=cwd,
214215
home=pathlib.Path.home(),
216+
preserve_cwd_label=workspace_root_arg in {".", "./"},
215217
)
216218

217219
summary_url = display_url or config_url
@@ -479,11 +481,18 @@ def _aggregate_items(items: list[tuple[str, t.Any]]) -> dict[str, t.Any]:
479481
cwd=cwd,
480482
)
481483
workspace_label = workspace_map.get(workspace_path)
484+
485+
if workspace_root_path is None:
486+
preserve_workspace_label = path is None
487+
else:
488+
preserve_workspace_label = workspace_root_path in {".", "./"}
489+
482490
if workspace_label is None:
483491
workspace_label = workspace_root_label(
484492
workspace_path,
485493
cwd=cwd,
486494
home=home,
495+
preserve_cwd_label=preserve_workspace_label,
487496
)
488497
workspace_map[workspace_path] = workspace_label
489498
raw_config.setdefault(workspace_label, {})

src/vcspull/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,12 +588,13 @@ def workspace_root_label(
588588
*,
589589
cwd: pathlib.Path | None = None,
590590
home: pathlib.Path | None = None,
591+
preserve_cwd_label: bool = True,
591592
) -> str:
592593
"""Create a normalized label for a workspace root path."""
593594
cwd = cwd or pathlib.Path.cwd()
594595
home = home or pathlib.Path.home()
595596

596-
if workspace_path == cwd:
597+
if preserve_cwd_label and workspace_path == cwd:
597598
return "./"
598599

599600
try:

0 commit comments

Comments
 (0)