Skip to content

Commit 1e84a78

Browse files
committed
cli/logging(refactor[privacy]): Wrap filesystem paths with PrivatePath
1 parent 7d27de8 commit 1e84a78

File tree

3 files changed

+53
-14
lines changed

3 files changed

+53
-14
lines changed

src/vcspull/cli/add.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ def handle_add_command(args: argparse.Namespace) -> None:
220220
repo_path = expand_dir(pathlib.Path(repo_input), cwd=cwd)
221221

222222
if not repo_path.exists():
223-
log.error("Repository path %s does not exist.", repo_path)
223+
log.error("Repository path %s does not exist.", PrivatePath(repo_path))
224224
return
225225

226226
if not repo_path.is_dir():
227-
log.error("Repository path %s is not a directory.", repo_path)
227+
log.error("Repository path %s is not a directory.", PrivatePath(repo_path))
228228
return
229229

230230
override_name = getattr(args, "override_name", None)
@@ -319,7 +319,11 @@ def handle_add_command(args: argparse.Namespace) -> None:
319319
response = ""
320320
proceed = response.strip().lower() in {"y", "yes"}
321321
if not proceed:
322-
log.info("Aborted import of '%s' from %s", repo_name, repo_path)
322+
log.info(
323+
"Aborted import of '%s' from %s",
324+
repo_name,
325+
PrivatePath(repo_path),
326+
)
323327
return
324328

325329
add_repo(
@@ -400,7 +404,10 @@ def add_repo(
400404
)
401405
return
402406
except Exception:
403-
log.exception("Error loading YAML from %s. Aborting.", config_file_path)
407+
log.exception(
408+
"Error loading YAML from %s. Aborting.",
409+
PrivatePath(config_file_path),
410+
)
404411
if log.isEnabledFor(logging.DEBUG):
405412
traceback.print_exc()
406413
return
@@ -579,7 +586,10 @@ def _prepare_no_merge_items(
579586
Style.RESET_ALL,
580587
)
581588
except Exception:
582-
log.exception("Error saving config to %s", config_file_path)
589+
log.exception(
590+
"Error saving config to %s",
591+
PrivatePath(config_file_path),
592+
)
583593
if log.isEnabledFor(logging.DEBUG):
584594
traceback.print_exc()
585595
elif (duplicate_merge_changes > 0 or config_was_relabelled) and dry_run:
@@ -635,7 +645,10 @@ def _prepare_no_merge_items(
635645
Style.RESET_ALL,
636646
)
637647
except Exception:
638-
log.exception("Error saving config to %s", config_file_path)
648+
log.exception(
649+
"Error saving config to %s",
650+
PrivatePath(config_file_path),
651+
)
639652
if log.isEnabledFor(logging.DEBUG):
640653
traceback.print_exc()
641654
return
@@ -719,7 +732,10 @@ def _prepare_no_merge_items(
719732
Style.RESET_ALL,
720733
)
721734
except Exception:
722-
log.exception("Error saving config to %s", config_file_path)
735+
log.exception(
736+
"Error saving config to %s",
737+
PrivatePath(config_file_path),
738+
)
723739
if log.isEnabledFor(logging.DEBUG):
724740
traceback.print_exc()
725741
return
@@ -778,6 +794,9 @@ def _prepare_no_merge_items(
778794
Style.RESET_ALL,
779795
)
780796
except Exception:
781-
log.exception("Error saving config to %s", config_file_path)
797+
log.exception(
798+
"Error saving config to %s",
799+
PrivatePath(config_file_path),
800+
)
782801
if log.isEnabledFor(logging.DEBUG):
783802
traceback.print_exc()

src/vcspull/cli/discover.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from colorama import Fore, Style
1313

1414
from vcspull._internal.config_reader import DuplicateAwareConfigReader
15+
from vcspull._internal.private_path import PrivatePath
1516
from vcspull.config import (
1617
canonicalize_workspace_path,
1718
expand_dir,
@@ -212,7 +213,10 @@ def discover_repos(
212213
)
213214
return
214215
except Exception:
215-
log.exception("Error loading YAML from %s. Aborting.", config_file_path)
216+
log.exception(
217+
"Error loading YAML from %s. Aborting.",
218+
PrivatePath(config_file_path),
219+
)
216220
if log.isEnabledFor(logging.DEBUG):
217221
traceback.print_exc()
218222
return
@@ -458,7 +462,10 @@ def discover_repos(
458462
Style.RESET_ALL,
459463
)
460464
except Exception:
461-
log.exception("Error saving config to %s", config_file_path)
465+
log.exception(
466+
"Error saving config to %s",
467+
PrivatePath(config_file_path),
468+
)
462469
if log.isEnabledFor(logging.DEBUG):
463470
traceback.print_exc()
464471
return
@@ -551,7 +558,10 @@ def discover_repos(
551558
Style.RESET_ALL,
552559
)
553560
except Exception:
554-
log.exception("Error saving config to %s", config_file_path)
561+
log.exception(
562+
"Error saving config to %s",
563+
PrivatePath(config_file_path),
564+
)
555565
if log.isEnabledFor(logging.DEBUG):
556566
traceback.print_exc()
557567
return

src/vcspull/cli/fmt.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from colorama import Fore, Style
1212

1313
from vcspull._internal.config_reader import DuplicateAwareConfigReader
14+
from vcspull._internal.private_path import PrivatePath
1415
from vcspull.config import (
1516
find_config_files,
1617
find_home_config_files,
@@ -176,10 +177,16 @@ def format_single_config(
176177
DuplicateAwareConfigReader.load_with_duplicates(config_file_path)
177178
)
178179
except TypeError:
179-
log.exception("Config file %s is not a mapping", config_file_path)
180+
log.exception(
181+
"Config file %s is not a mapping",
182+
PrivatePath(config_file_path),
183+
)
180184
return False
181185
except Exception:
182-
log.exception("Error loading config from %s", config_file_path)
186+
log.exception(
187+
"Error loading config from %s",
188+
PrivatePath(config_file_path),
189+
)
183190
if log.isEnabledFor(logging.DEBUG):
184191
traceback.print_exc()
185192
return False
@@ -359,7 +366,10 @@ def format_single_config(
359366
Style.RESET_ALL,
360367
)
361368
except Exception:
362-
log.exception("Error saving formatted config to %s", config_file_path)
369+
log.exception(
370+
"Error saving formatted config to %s",
371+
PrivatePath(config_file_path),
372+
)
363373
if log.isEnabledFor(logging.DEBUG):
364374
traceback.print_exc()
365375
return False

0 commit comments

Comments
 (0)