aboutsummaryrefslogtreecommitdiff
path: root/git.py
diff options
context:
space:
mode:
Diffstat (limited to 'git.py')
-rw-r--r--git.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/git.py b/git.py
index deddeba..7e7ad74 100644
--- a/git.py
+++ b/git.py
@@ -207,11 +207,13 @@ class Repo:
"""Returns a GitCommand() on our path."""
return GitCommand(self.path, cmd)
- def for_each_ref(self, pattern = None, sort = None):
+ def for_each_ref(self, pattern = None, sort = None, count = None):
"""Returns a list of references."""
cmd = self.cmd('for-each-ref')
if sort:
cmd.sort = sort
+ if count:
+ cmd.count = count
if pattern:
cmd.arg(pattern)
@@ -347,6 +349,15 @@ class Repo:
return out.read()
+ def last_commit_timestamp(self):
+ """Return the timestamp of the last commit."""
+ refs = self.for_each_ref(pattern = 'refs/heads/',
+ sort = '-committerdate', count = 1)
+ for obj_id, _, _ in refs:
+ commit = self.commit(obj_id)
+ return commit.committer_epoch
+ return -1
+
class Commit (object):
"""A git commit."""