File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 1- from head import Head
21from git .util import join_path
32from gitdb .util import (
43 join ,
@@ -170,7 +169,7 @@ def _serialize(self, stream):
170169 write = stream .write
171170
172171 # write all entries
173- for i , e in enumerate ( self ) :
172+ for e in self :
174173 write (repr (e ))
175174 #END for each entry
176175
Original file line number Diff line number Diff line change 1616 hex_to_bin
1717 )
1818
19+ from log import RefLog
20+
1921__all__ = ["SymbolicReference" ]
2022
2123class SymbolicReference (object ):
@@ -270,6 +272,14 @@ def is_detached(self):
270272 except TypeError :
271273 return True
272274
275+ def log (self ):
276+ """
277+ :return: RefLog for this reference. Its last entry reflects the latest change
278+ applied to this reference
279+
280+ .. note:: As the log is parsed every time, its recommended to cache it for use
281+ instead of calling this method repeatedly"""
282+ return RefLog .from_file (RefLog .path (self ))
273283
274284 @classmethod
275285 def to_full_path (cls , path ):
Original file line number Diff line number Diff line change @@ -488,3 +488,6 @@ def test_head_reset(self, rw_repo):
488488 def test_dereference_recursive (self ):
489489 # for now, just test the HEAD
490490 assert SymbolicReference .dereference_recursive (self .rorepo , 'HEAD' )
491+
492+ def test_reflog (self ):
493+ assert isinstance (self .rorepo .heads .master .log (), RefLog )
You can’t perform that action at this time.
0 commit comments