Klaus Demo klaus / 62d08c3
When determining last update to a repository, ignore refs that point at missing objects. (#239) * When finding last update, ignore refs that point at missing objects. * Don't break when sorting refs where some refs point at non-existing objects. Jelmer Vernooń≥ authored 5 months ago Jonas Haag committed 5 months ago
1 changed file(s) with 13 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
3030
3131 def get_last_updated_at(self):
3232 """Get datetime of last commit to this repository."""
33 refs = [self[ref_hash] for ref_hash in self.get_refs().values()]
33 refs = []
34 for ref_hash in self.get_refs().values():
35 try:
36 refs.append(self[ref_hash])
37 except KeyError:
38 # Whoops. The ref points at a non-existant object
39 pass
3440 refs.sort(key=lambda obj:getattr(obj, 'commit_time', float('-inf')),
3541 reverse=True)
3642 for ref in refs:
9399 time they have been committed to last.
94100 """
95101 def get_commit_time(refname):
96 obj = self[refs[refname]]
102 try:
103 obj = self[refs[refname]]
104 except KeyError:
105 # Default to 0, i.e. sorting refs that point at non-existant
106 # objects last.
107 return 0
97108 if isinstance(obj, dulwich.objects.Tag):
98109 return obj.tag_time
99110 return obj.commit_time