@@ -116,6 +116,22 @@ def to_progress_instance(progress: Union[Callable[..., Any], RemoteProgress, Non
116116return progress
117117
118118
119+ class PushInfoList (IterableList ):
120+ def __new__ (cls )-> 'IterableList[IterableObj]' :
121+ return super (IterableList ,cls ).__new__ (cls ,'push_infos' )
122+
123+ def __init__ (self )-> None :
124+ super ().__init__ ('push_infos' )
125+ self .exception = None
126+
127+ def raise_on_error (self ):
128+ """
129+ Raise an exception if any ref failed to push.
130+ """
131+ if self .exception :
132+ raise self .exception
133+
134+
119135class PushInfo (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
775791def _get_push_info (self ,proc :'Git.AutoInterrupt' ,
776792progress :Union [Callable [...,Any ],RemoteProgress ,None ],
777- kill_after_timeout :Union [None ,float ]= None )-> IterableList [ PushInfo ] :
793+ kill_after_timeout :Union [None ,float ]= None )-> PushInfoList :
778794progress = 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
784800progress_handler = progress .new_message_handler ()
785- output :IterableList [ PushInfo ] = IterableList ( 'push_infos' )
801+ output :PushInfoList = PushInfoList ( )
786802
787803def stdout_handler (line :str )-> None :
788804try :
@@ -796,13 +812,14 @@ def stdout_handler(line: str) -> None:
796812stderr_text = progress .error_lines and '\n ' .join (progress .error_lines )or ''
797813try :
798814proc .wait (stderr = stderr_text )
799- except Exception :
815+ except Exception as e :
800816# This is different than fetch (which fails if there is any std_err
801817# even if there is an output)
802818if not output :
803819raise
804820elif stderr_text :
805821log .warning ("Error lines received while fetching: %s" ,stderr_text )
822+ output .exception = e
806823
807824return output
808825