Skip to content

Let remote.push return a PushInfoList #1360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 13, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Extend IterableList[PushInfo] instead of IterableList
  • Loading branch information
Sjord committed Nov 10, 2021
commit a270deb86c98123497bb1930cded712fe0c8895e
33 changes: 16 additions & 17 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,6 @@ def to_progress_instance(progress: Union[Callable[..., Any], RemoteProgress, Non
return progress


class PushInfoList(IterableList):
def __new__(cls) -> 'PushInfoList':
base = super().__new__(cls, 'push_infos')
return cast(PushInfoList, base)

def __init__(self) -> None:
super().__init__('push_infos')
self.error: Optional[Exception] = None

def raise_if_error(self) -> None:
"""
Raise an exception if any ref failed to push.
"""
if self.error:
raise self.error


class PushInfo(IterableObj, object):
"""
Carries information about the result of a push operation of a single head::
Expand Down Expand Up @@ -252,6 +235,22 @@ def iter_items(cls, repo: 'Repo', *args: Any, **kwargs: Any
raise NotImplementedError


class PushInfoList(IterableList[PushInfo]):
def __new__(cls) -> 'PushInfoList':
return cast(PushInfoList, IterableList.__new__(cls, 'push_infos'))

def __init__(self) -> None:
super().__init__('push_infos')
self.error: Optional[Exception] = None

def raise_if_error(self) -> None:
"""
Raise an exception if any ref failed to push.
"""
if self.error:
raise self.error


class FetchInfo(IterableObj, object):

"""
Expand Down