git @ Cat's Eye Technologies klaus / a4b72b4
Refactoring Jonas Haag 9 years ago
2 changed file(s) with 20 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
00 {% extends 'base.html' %}
11
2 {% block extra_header %}{% endblock %} {# no branch selector on commits #}
2 {% block extra_header %}{% endblock %} {# hide branch selector #}
33
44 {% block title %}
55 Commit {{ rev }} - {{ repo.name }}
3939 return current_app.send_static_file('robots.txt')
4040
4141
42 def _get_repo_and_rev(repo, rev=None):
43 try:
44 repo = current_app.repos[repo]
45 except KeyError:
46 raise NotFound("No such repository %r" % repo)
47
48 if rev is None:
49 rev = repo.get_default_branch()
50 if rev is None:
51 raise NotFound("Empty repository")
52 try:
53 commit = repo.get_commit(rev)
54 except KeyError:
55 raise NotFound("No such commit %r" % rev)
56
57 return repo, rev, commit
58
59
4260 class BaseRepoView(View):
4361 """Base for all views with a repo context.
4462
6381 return render_template(self.template_name, **self.context)
6482
6583 def make_template_context(self, repo, rev, path):
66 try:
67 repo = current_app.repos[repo]
68 except KeyError:
69 raise NotFound("No such repository %r" % repo)
70
71 if rev is None:
72 rev = repo.get_default_branch()
73 if rev is None:
74 raise NotFound("Empty repository")
75 try:
76 commit = repo.get_commit(rev)
77 except KeyError:
78 raise NotFound("No such commit %r" % rev)
79
84 repo, rev, commit = _get_repo_and_rev(repo, rev)
8085 try:
8186 blob_or_tree = repo.get_blob_or_tree(commit, path)
8287 except KeyError: