Skip to content

Commit a77f446

Browse files
committed
src/cli,config(fix[workspace-label]): fix workspace resolution for path-first adds
why: Path-first adds should derive workspace from repo parent directory, and handle home directory edge case. what: - _resolve_workspace_path returns repo.parent when workspace_root is None - workspace_root_label handles workspace_path == home to return ~/ - Prevents ~/./ labels when workspace is the home directory refs: Path-first workflow correctness
1 parent de439b7 commit a77f446

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/vcspull/cli/add.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ def _resolve_workspace_path(
120120
if workspace_root:
121121
return canonicalize_workspace_path(workspace_root, cwd=cwd)
122122
if repo_path_str:
123-
return expand_dir(pathlib.Path(repo_path_str), cwd)
123+
repo_path = expand_dir(pathlib.Path(repo_path_str), cwd)
124+
return repo_path.parent
124125
return cwd
125126

126127

@@ -515,10 +516,7 @@ def _prepare_no_merge_items(
515516
found_label = current_label
516517
break
517518

518-
if found_label is None:
519-
workspace_label = preferred_label
520-
else:
521-
workspace_label = found_label
519+
workspace_label = preferred_label if found_label is None else found_label
522520

523521
for idx in matching_indexes:
524522
if items[idx]["label"] == "./" and workspace_label != "./":

src/vcspull/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,9 @@ def workspace_root_label(
597597
if preserve_cwd_label and workspace_path == cwd:
598598
return "./"
599599

600+
if workspace_path == home:
601+
return "~/"
602+
600603
try:
601604
relative_to_home = workspace_path.relative_to(home)
602605
label = f"~/{relative_to_home.as_posix()}"

0 commit comments

Comments
 (0)