@@ -116,6 +116,22 @@ def to_progress_instance(progress: Union[Callable[..., Any], RemoteProgress, Non
116
116
return progress
117
117
118
118
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
+
119
135
class PushInfo (IterableObj , object ):
120
136
"""
121
137
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',
774
790
775
791
def _get_push_info (self , proc : 'Git.AutoInterrupt' ,
776
792
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 :
778
794
progress = to_progress_instance (progress )
779
795
780
796
# read progress information from stderr
781
797
# we hope stdout can hold all the data, it should ...
782
798
# read the lines manually as it will use carriage returns between the messages
783
799
# to override the previous one. This is why we read the bytes manually
784
800
progress_handler = progress .new_message_handler ()
785
- output : IterableList [ PushInfo ] = IterableList ( 'push_infos' )
801
+ output : PushInfoList = PushInfoList ( )
786
802
787
803
def stdout_handler (line : str ) -> None :
788
804
try :
@@ -796,13 +812,14 @@ def stdout_handler(line: str) -> None:
796
812
stderr_text = progress .error_lines and '\n ' .join (progress .error_lines ) or ''
797
813
try :
798
814
proc .wait (stderr = stderr_text )
799
- except Exception :
815
+ except Exception as e :
800
816
# This is different than fetch (which fails if there is any std_err
801
817
# even if there is an output)
802
818
if not output :
803
819
raise
804
820
elif stderr_text :
805
821
log .warning ("Error lines received while fetching: %s" , stderr_text )
822
+ output .exception = e
806
823
807
824
return output
808
825
0 commit comments