Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions src/vcspull/cli/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import logging
import pathlib
import subprocess
import traceback
import typing as t

from colorama import Fore, Style
Expand Down Expand Up @@ -408,8 +407,6 @@ def add_repo(
"Error loading YAML from %s. Aborting.",
PrivatePath(config_file_path),
)
if log.isEnabledFor(logging.DEBUG):
traceback.print_exc()
return
else:
raw_config = {}
Expand Down Expand Up @@ -589,8 +586,6 @@ def _prepare_no_merge_items(
"Error saving config to %s",
PrivatePath(config_file_path),
)
if log.isEnabledFor(logging.DEBUG):
traceback.print_exc()
elif (duplicate_merge_changes > 0 or config_was_relabelled) and dry_run:
log.info(
"%s→%s Would save workspace label adjustments to %s%s%s.",
Expand Down Expand Up @@ -648,8 +643,6 @@ def _prepare_no_merge_items(
"Error saving config to %s",
PrivatePath(config_file_path),
)
if log.isEnabledFor(logging.DEBUG):
traceback.print_exc()
return

ordered_items = _build_ordered_items(top_level_items, raw_config)
Expand Down Expand Up @@ -735,8 +728,6 @@ def _prepare_no_merge_items(
"Error saving config to %s",
PrivatePath(config_file_path),
)
if log.isEnabledFor(logging.DEBUG):
traceback.print_exc()
return

target_section = ordered_items[target_index]["section"]
Expand Down Expand Up @@ -797,5 +788,3 @@ def _prepare_no_merge_items(
"Error saving config to %s",
PrivatePath(config_file_path),
)
if log.isEnabledFor(logging.DEBUG):
traceback.print_exc()
7 changes: 0 additions & 7 deletions src/vcspull/cli/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import os
import pathlib
import subprocess
import traceback
import typing as t

from colorama import Fore, Style
Expand Down Expand Up @@ -331,8 +330,6 @@ def discover_repos(
"Error loading YAML from %s. Aborting.",
PrivatePath(config_file_path),
)
if log.isEnabledFor(logging.DEBUG):
traceback.print_exc()
return
if raw_config is None:
raw_config = {}
Expand Down Expand Up @@ -609,8 +606,6 @@ def discover_repos(
"Error saving config to %s",
PrivatePath(config_file_path),
)
if log.isEnabledFor(logging.DEBUG):
traceback.print_exc()
return
return

Expand Down Expand Up @@ -710,8 +705,6 @@ def discover_repos(
"Error saving config to %s",
PrivatePath(config_file_path),
)
if log.isEnabledFor(logging.DEBUG):
traceback.print_exc()
return
else:
log.info(
Expand Down
5 changes: 0 additions & 5 deletions src/vcspull/cli/fmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import copy
import logging
import pathlib
import traceback
import typing as t

from colorama import Fore, Style
Expand Down Expand Up @@ -188,8 +187,6 @@ def format_single_config(
"Error loading config from %s",
PrivatePath(config_file_path),
)
if log.isEnabledFor(logging.DEBUG):
traceback.print_exc()
return False

# Format the configuration
Expand Down Expand Up @@ -371,8 +368,6 @@ def format_single_config(
"Error saving formatted config to %s",
PrivatePath(config_file_path),
)
if log.isEnabledFor(logging.DEBUG):
traceback.print_exc()
return False
else:
log.info(
Expand Down
5 changes: 1 addition & 4 deletions src/vcspull/cli/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,7 @@ def silent_progress(output: str, timestamp: datetime) -> None:
"Failed syncing %s",
repo_name,
)
if log.isEnabledFor(logging.DEBUG):
import traceback

traceback.print_exc()
log.debug("Traceback for %s", repo_name, exc_info=True)
formatter.emit_text(
f"{colors.error('✗')} Failed syncing {colors.info(repo_name)}: "
f"{colors.error(str(e))}",
Expand Down
56 changes: 56 additions & 0 deletions tests/cli/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""Shared test helpers for vcspull CLI tests."""

from __future__ import annotations

import typing as t

from vcspull._internal.remotes import (
ImportOptions,
RemoteRepo,
)


class MockImporter:
"""Reusable mock importer for tests."""

def __init__(
self,
*,
service_name: str = "MockService",
repos: list[RemoteRepo] | None = None,
error: Exception | None = None,
) -> None:
self.service_name = service_name
self._repos = repos or []
self._error = error

def fetch_repos(
self,
options: ImportOptions,
) -> t.Iterator[RemoteRepo]:
"""Yield mock repos or raise a mock error."""
if self._error:
raise self._error
yield from self._repos


class CapturingMockImporter:
"""Mock importer that captures the ImportOptions passed to fetch_repos."""

def __init__(
self,
*,
service_name: str = "MockService",
repos: list[RemoteRepo] | None = None,
) -> None:
self.service_name = service_name
self._repos = repos or []
self.captured_options: ImportOptions | None = None

def fetch_repos(
self,
options: ImportOptions,
) -> t.Iterator[RemoteRepo]:
"""Capture options and yield repos."""
self.captured_options = options
yield from self._repos
47 changes: 1 addition & 46 deletions tests/cli/test_import_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import pytest

from tests.cli.conftest import CapturingMockImporter, MockImporter
from vcspull._internal.remotes import (
AuthenticationError,
ConfigurationError,
Expand Down Expand Up @@ -55,52 +56,6 @@ def _make_repo(
)


class MockImporter:
"""Reusable mock importer for tests."""

def __init__(
self,
*,
service_name: str = "MockService",
repos: list[RemoteRepo] | None = None,
error: Exception | None = None,
) -> None:
self.service_name = service_name
self._repos = repos or []
self._error = error

def fetch_repos(
self,
options: ImportOptions,
) -> t.Iterator[RemoteRepo]:
"""Yield mock repos or raise a mock error."""
if self._error:
raise self._error
yield from self._repos


class CapturingMockImporter:
"""Mock importer that captures the ImportOptions passed to fetch_repos."""

def __init__(
self,
*,
service_name: str = "MockService",
repos: list[RemoteRepo] | None = None,
) -> None:
self.service_name = service_name
self._repos = repos or []
self.captured_options: ImportOptions | None = None

def fetch_repos(
self,
options: ImportOptions,
) -> t.Iterator[RemoteRepo]:
"""Capture options and yield repos."""
self.captured_options = options
yield from self._repos


class ResolveConfigFixture(t.NamedTuple):
"""Fixture for _resolve_config_file test cases."""

Expand Down