diff options
-rw-r--r-- | refs/log.py | 3 | ||||
-rw-r--r-- | refs/symbolic.py | 10 | ||||
-rw-r--r-- | test/test_refs.py | 3 |
3 files changed, 14 insertions, 2 deletions
diff --git a/refs/log.py b/refs/log.py index e7f18c6a..1d07ef9a 100644 --- a/refs/log.py +++ b/refs/log.py @@ -1,4 +1,3 @@ -from head import Head from git.util import join_path from gitdb.util import ( join, @@ -170,7 +169,7 @@ class RefLog(list, Serializable): write = stream.write # write all entries - for i, e in enumerate(self): + for e in self: write(repr(e)) #END for each entry diff --git a/refs/symbolic.py b/refs/symbolic.py index 3329d51c..9dd7629c 100644 --- a/refs/symbolic.py +++ b/refs/symbolic.py @@ -16,6 +16,8 @@ from gitdb.util import ( hex_to_bin ) +from log import RefLog + __all__ = ["SymbolicReference"] class SymbolicReference(object): @@ -270,6 +272,14 @@ class SymbolicReference(object): except TypeError: return True + def log(self): + """ + :return: RefLog for this reference. Its last entry reflects the latest change + applied to this reference + + .. note:: As the log is parsed every time, its recommended to cache it for use + instead of calling this method repeatedly""" + return RefLog.from_file(RefLog.path(self)) @classmethod def to_full_path(cls, path): diff --git a/test/test_refs.py b/test/test_refs.py index ebf1a00d..1f3dfb9f 100644 --- a/test/test_refs.py +++ b/test/test_refs.py @@ -488,3 +488,6 @@ class TestRefs(TestBase): def test_dereference_recursive(self): # for now, just test the HEAD assert SymbolicReference.dereference_recursive(self.rorepo, 'HEAD') + + def test_reflog(self): + assert isinstance(self.rorepo.heads.master.log(), RefLog) |