Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3b82fa3

Browse files
SjordByron
authored andcommitted
Let remote.push return a PushInfoList
List-like, so that it's backward compatible. But it has a new methodraise_on_error, that throws an exception if anything failed to push.Related to#621
1 parenta3efd24 commit3b82fa3

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

‎git/remote.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,22 @@ def to_progress_instance(progress: Union[Callable[..., Any], RemoteProgress, Non
116116
returnprogress
117117

118118

119+
classPushInfoList(IterableList):
120+
def__new__(cls)->'IterableList[IterableObj]':
121+
returnsuper(IterableList,cls).__new__(cls,'push_infos')
122+
123+
def__init__(self)->None:
124+
super().__init__('push_infos')
125+
self.exception=None
126+
127+
defraise_on_error(self):
128+
"""
129+
Raise an exception if any ref failed to push.
130+
"""
131+
ifself.exception:
132+
raiseself.exception
133+
134+
119135
classPushInfo(IterableObj,object):
120136
"""
121137
Carries information about the result of a push operation of a single head::
@@ -774,15 +790,15 @@ def _get_fetch_info_from_stderr(self, proc: 'Git.AutoInterrupt',
774790

775791
def_get_push_info(self,proc:'Git.AutoInterrupt',
776792
progress:Union[Callable[...,Any],RemoteProgress,None],
777-
kill_after_timeout:Union[None,float]=None)->IterableList[PushInfo]:
793+
kill_after_timeout:Union[None,float]=None)->PushInfoList:
778794
progress=to_progress_instance(progress)
779795

780796
# read progress information from stderr
781797
# we hope stdout can hold all the data, it should ...
782798
# read the lines manually as it will use carriage returns between the messages
783799
# to override the previous one. This is why we read the bytes manually
784800
progress_handler=progress.new_message_handler()
785-
output:IterableList[PushInfo]=IterableList('push_infos')
801+
output:PushInfoList=PushInfoList()
786802

787803
defstdout_handler(line:str)->None:
788804
try:
@@ -796,13 +812,14 @@ def stdout_handler(line: str) -> None:
796812
stderr_text=progress.error_linesand'\n'.join(progress.error_lines)or''
797813
try:
798814
proc.wait(stderr=stderr_text)
799-
exceptException:
815+
exceptExceptionase:
800816
# This is different than fetch (which fails if there is any std_err
801817
# even if there is an output)
802818
ifnotoutput:
803819
raise
804820
elifstderr_text:
805821
log.warning("Error lines received while fetching: %s",stderr_text)
822+
output.exception=e
806823

807824
returnoutput
808825

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp