summaryrefslogtreecommitdiff
path: root/git.py
diff options
context:
space:
mode:
authorAlberto Bertogli <albertito@blitiri.com.ar>2013-11-02 23:18:33 +0100
committerAlberto Bertogli <albertito@blitiri.com.ar>2013-11-02 23:18:33 +0100
commite49c69da2e53c8938f4d58bd478bb68f060e3849 (patch)
tree360cfbebf9faf3d9a48847bfa5f594b11e8538cc /git.py
parent6764bfcfd6bfb5e1aafc777fea9cfe00139710f2 (diff)
downloadgit-arr-fork-e49c69da2e53c8938f4d58bd478bb68f060e3849.zip
Show the age of a repository in the index, via javascript
This patch adds the age of the repository to the index view, using javascript to give a nice human string for the age. When javascript is not available, the element remains hidden. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
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."""