@@ -49,6 +49,38 @@ class Remote(LazyMixin, Iterable):
4949 __slots__ = ( "repo" , "name" , "_config_reader" )
5050 _id_attribute_ = "name"
5151
52+ class FetchInfo (object ):
53+ """
54+ Carries information about the results of a fetch operation::
55+
56+ info = remote.fetch()[0]
57+ info.local_ref # None, or Reference object to the local head or tag which was moved
58+ info.remote_ref # Symbolic Reference or RemoteReference to the changed remote head or FETCH_HEAD
59+ info.flags # additional flags to be & with enumeration members, i.e. info.flags & info.REJECTED
60+ """
61+ __slots__ = tuple ()
62+ BRANCH_UPTODATE , REJECTED , FORCED_UPDATED , FAST_FORWARD , NEW_TAG , \
63+ TAG_UPDATE , NEW_BRANCH = [ 1 << x for x in range (1 ,8 ) ]
64+
65+ def __init__ (self , local_ref , remote_ref , flags ):
66+ """
67+ Initialize a new instance
68+ """
69+ self .local_ref = local_ref
70+ self .remote_ref = remote_ref
71+ self .flags = flags
72+
73+ @classmethod
74+ def _from_line (cls , line ):
75+ """
76+ Parse information from the given line as returned by git-fetch -v
77+ and return a new FetchInfo object representing this information.
78+ """
79+ raise NotImplementedError ("todo" )
80+
81+ # END FetchInfo definition
82+
83+
5284 def __init__ (self , repo , name ):
5385 """
5486 Initialize a remote instance
@@ -218,10 +250,11 @@ def fetch(self, refspec=None, **kwargs):
218250 Additional arguments to be passed to git-fetch
219251
220252 Returns
221- self
253+ list(FetchInfo, ...) list of FetchInfo instances providing detailed
254+ information about the fetch results
222255 """
223- self .repo .git .fetch (self , refspec , ** kwargs )
224- return self
256+ lines = self .repo .git .fetch (self , refspec , v = True , ** kwargs ). splitlines ( )
257+ return [ self . FetchInfo . _from_line ( line ) for line in lines ]
225258
226259 def pull (self , refspec = None , ** kwargs ):
227260 """
@@ -235,10 +268,10 @@ def pull(self, refspec=None, **kwargs):
235268 Additional arguments to be passed to git-pull
236269
237270 Returns
238- self
271+ list(Fetch
239272 """
240- self .repo .git .pull (self , refspec , ** kwargs )
241- return self
273+ lines = self .repo .git .pull (self , refspec , v = True , ** kwargs ). splitlines ( )
274+ return [ self . FetchInfo . _from_line ( line ) for line in lines ]
242275
243276 def push (self , refspec = None , ** kwargs ):
244277 """
0 commit comments