Skip to content

Commit 392e80c

Browse files
committed
cli/add_from_fs(feat[output]): Add detailed reporting of existing repositories
why: Users need visibility into which repositories already exist in configuration and where they are located. what: - Show count and detailed list of existing repositories when found - Display repository name, URL, config path, and file location for each existing repo - Simplify logic by consolidating duplicate repository checking code - Improve user experience with more informative output
1 parent 3da21db commit 392e80c

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

src/vcspull/cli/add_from_fs.py

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -222,38 +222,30 @@ def add_from_filesystem(
222222
return
223223

224224
repos_to_add: list[tuple[str, str, str]] = []
225-
if not yes:
226-
for name, url, key in found_repos:
227-
target_section = raw_config.get(key, {})
228-
if isinstance(target_section, dict) and name in target_section:
229-
pass
230-
else:
231-
repos_to_add.append((name, url, key))
232-
233-
if not repos_to_add:
234-
log.info(
235-
"All found repositories already exist in the configuration. "
236-
"Nothing to do.",
237-
)
238-
return
225+
existing_repos: list[tuple[str, str, str]] = [] # (name, url, key)
226+
227+
for name, url, key in found_repos:
228+
target_section = raw_config.get(key, {})
229+
if isinstance(target_section, dict) and name in target_section:
230+
existing_repos.append((name, url, key))
231+
else:
232+
repos_to_add.append((name, url, key))
233+
234+
if existing_repos:
235+
log.info(f"Found {len(existing_repos)} existing repositories in configuration:")
236+
for name, url, key in existing_repos:
237+
log.info(f" - {name} ({url}) at {key}{name} in {config_file_path}")
238+
239+
if not repos_to_add:
240+
if existing_repos:
241+
log.info("All found repositories already exist in the configuration. Nothing to do.")
242+
return
239243

244+
if not yes:
240245
confirm = input("Add these repositories? [y/N]: ").lower()
241246
if confirm not in {"y", "yes"}:
242247
log.info("Aborted by user.")
243248
return
244-
else:
245-
for name, url, key in found_repos:
246-
target_section = raw_config.get(key, {})
247-
if isinstance(target_section, dict) and name in target_section:
248-
log.info(f"Repository {key}{name} ({url}) already exists. Skipping.")
249-
else:
250-
repos_to_add.append((name, url, key))
251-
if not repos_to_add:
252-
log.info(
253-
"All found repositories already exist in the configuration or were "
254-
"skipped. Nothing to do.",
255-
)
256-
return
257249

258250
changes_made = False
259251
for repo_name, repo_url, determined_base_key in repos_to_add:

0 commit comments

Comments
 (0)