Shorten SHA1 sums in breadcrumbs and branch selector.
Jonas Haag
13 years ago
175 | 175 |
return match.group(1).strip()
|
176 | 176 |
return email
|
177 | 177 |
|
|
178 |
def shorten_sha1(sha1):
|
|
179 |
if re.match('[a-z\d]{20,40}', sha1):
|
|
180 |
sha1 = sha1[:10]
|
|
181 |
return sha1
|
|
182 |
|
178 | 183 |
app.jinja_env.filters['u'] = force_unicode
|
179 | 184 |
app.jinja_env.filters['timesince'] = timesince
|
180 | |
app.jinja_env.filters['shorten_id'] = lambda id: id[:7] if len(id) in {20, 40} else id
|
|
185 |
app.jinja_env.filters['shorten_sha1'] = shorten_sha1
|
181 | 186 |
app.jinja_env.filters['shorten_message'] = lambda msg: msg.split('\n')[0]
|
182 | 187 |
app.jinja_env.filters['pygmentize'] = pygmentize
|
183 | 188 |
app.jinja_env.filters['is_binary'] = guess_is_binary
|
3 | 3 |
<span>
|
4 | 4 |
<a href="{{ build_url('history', commit_id='master') }}">{{ repo.name }}</a>
|
5 | 5 |
<span class=slash>/</span>
|
6 | |
<a href="{{ build_url('history') }}">{{ commit_id }}</a>
|
|
6 |
<a href="{{ build_url('history') }}">{{ commit_id|shorten_sha1 }}</a>
|
7 | 7 |
</span>
|
8 | 8 |
|
9 | 9 |
{% if subpaths %}
|
|
22 | 22 |
|
23 | 23 |
{% block extra_header %}
|
24 | 24 |
<div class=branch-selector>
|
25 | |
<span>{{ commit_id }}</span>
|
|
25 |
<span>{{ commit_id|shorten_sha1 }}</span>
|
26 | 26 |
<ul>
|
27 | 27 |
{% for branch in branches %}
|
28 | 28 |
<li><a href="{{ build_url(commit_id=branch, path=path) }}">{{ branch }}</a></li>
|
0 | 0 |
<div class=tree>
|
1 | |
<h2>Tree @<a href="{{ build_url('view_commit') }}">{{ commit_id|shorten_id }}</a></h2>
|
|
1 |
<h2>Tree @<a href="{{ build_url('view_commit') }}">{{ commit_id|shorten_sha1 }}</a></h2>
|
2 | 2 |
<ul>
|
3 | 3 |
{% for _, name, fullpath in tree.dirs %}
|
4 | 4 |
<li><a href="{{ build_url('history', path=fullpath) }}" class=dir>{{ name|u }}</a></li>
|
6 | 6 |
<h2>
|
7 | 7 |
{{ filename|u }}
|
8 | 8 |
<span>
|
9 | |
@<a href="{{ build_url('view_commit') }}">{{ commit_id|shorten_id }}</a>
|
|
9 |
@<a href="{{ build_url('view_commit') }}">{{ commit_id|shorten_sha1 }}</a>
|
10 | 10 |
(<a href="{{ raw_url }}">raw</a>
|
11 | 11 |
· <a href="{{ build_url('history', path=path) }}">history</a>)
|
12 | 12 |
</span>
|