@@ -116,6 +116,22 @@ def to_progress_instance(progress: Union[Callable[..., Any], RemoteProgress, Non
116116 return 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
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 def stdout_handler (line : str ) -> None :
788804 try :
@@ -796,13 +812,14 @@ def stdout_handler(line: str) -> None:
796812 stderr_text = progress .error_lines and '\n ' .join (progress .error_lines ) or ''
797813 try :
798814 proc .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)
802818 if not output :
803819 raise
804820 elif stderr_text :
805821 log .warning ("Error lines received while fetching: %s" , stderr_text )
822+ output .exception = e
806823
807824 return output
808825
0 commit comments