Skip to content

Commit

Permalink
prevent progress indicator from overwriting interactive git ssh output
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarn committed Aug 17, 2024
1 parent 3175fb0 commit f29a453
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from poetry.puzzle.exceptions import OverrideNeeded
from poetry.repositories.exceptions import PackageNotFound
from poetry.utils.helpers import get_file_hash
from poetry.utils import pause_indicator


if TYPE_CHECKING:
Expand Down Expand Up @@ -105,6 +106,11 @@ def _formatter_elapsed(self) -> str:

return f"{elapsed:.1f}s"

def _display(self, *args, **kwargs):
if pause_indicator.is_paused():
return
super()._display(*args, **kwargs)


class Provider:
UNSAFE_PACKAGES: ClassVar[set[str]] = set()
Expand Down
20 changes: 20 additions & 0 deletions src/poetry/utils/pause_indicator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

from threading import Lock

_lock = Lock()
_counter = 0

def is_paused():
return _counter != 0

class IndicatorPaused:
def __enter__(self):
global _counter
with _lock:
_counter += 1

def __exit__(self, *exc):
global _counter
with _lock:
_counter -= 1
assert _counter >= 0
12 changes: 7 additions & 5 deletions src/poetry/vcs/git/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from poetry.console.exceptions import PoetryConsoleError
from poetry.utils.authenticator import get_default_authenticator
from poetry.utils.helpers import remove_directory
from poetry.utils.pause_indicator import IndicatorPaused


if TYPE_CHECKING:
Expand Down Expand Up @@ -207,11 +208,12 @@ def _fetch_remote_refs(cls, url: str, local: Repo) -> FetchPackResult:
client, path = get_transport_and_path(url, config=config, **kwargs)

with local:
result: FetchPackResult = client.fetch(
path,
local,
determine_wants=local.object_store.determine_wants_all,
)
with IndicatorPaused():
result: FetchPackResult = client.fetch(
path,
local,
determine_wants=local.object_store.determine_wants_all,
)
return result

@staticmethod
Expand Down

0 comments on commit f29a453

Please sign in to comment.