1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import os
from .page import Page
def ref_names_for_commit(refs, commit_sha):
ref_names = []
if refs is None:
return ref_names
for ref in refs:
if ref.commit.hexsha == commit_sha:
ref_names.append(ref.name)
return ref_names
class LogPage(Page):
def __init__(self, out_dir, name, commits, branches, tags, content_subdir):
super(LogPage, self).__init__('log.md', out_dir, 'l.md', name, content_subdir)
self.commits = commits
self.branches = branches
self.tags = tags
def _commits_with_refs(self):
commits_context = []
for commit in self.commits:
refs = ref_names_for_commit(self.branches, commit.hexsha) + ref_names_for_commit(self.tags, commit.hexsha)
commit_context = {
'committed_datetime': commit.committed_datetime,
'hexsha': commit.hexsha,
'refs': refs,
'summary': commit.summary
}
commits_context.append(commit_context)
return commits_context
def context(self):
commits_context = []
if self.commits is not None:
commits_context = self._commits_with_refs()
return {
'commits': commits_context,
'content_subdir': self.content_subdir,
'title': self.name + ': Log'
}
|