git @ Cat's Eye Technologies klaus / 7c0ba02
Shorten SHA1 sums in breadcrumbs and branch selector. Jonas Haag 13 years ago
4 changed file(s) with 10 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
175175 return match.group(1).strip()
176176 return email
177177
178 def shorten_sha1(sha1):
179 if re.match('[a-z\d]{20,40}', sha1):
180 sha1 = sha1[:10]
181 return sha1
182
178183 app.jinja_env.filters['u'] = force_unicode
179184 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
181186 app.jinja_env.filters['shorten_message'] = lambda msg: msg.split('\n')[0]
182187 app.jinja_env.filters['pygmentize'] = pygmentize
183188 app.jinja_env.filters['is_binary'] = guess_is_binary
33 <span>
44 <a href="{{ build_url('history', commit_id='master') }}">{{ repo.name }}</a>
55 <span class=slash>/</span>
6 <a href="{{ build_url('history') }}">{{ commit_id }}</a>
6 <a href="{{ build_url('history') }}">{{ commit_id|shorten_sha1 }}</a>
77 </span>
88
99 {% if subpaths %}
2222
2323 {% block extra_header %}
2424 <div class=branch-selector>
25 <span>{{ commit_id }}</span>
25 <span>{{ commit_id|shorten_sha1 }}</span>
2626 <ul>
2727 {% for branch in branches %}
2828 <li><a href="{{ build_url(commit_id=branch, path=path) }}">{{ branch }}</a></li>
00 <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>
22 <ul>
33 {% for _, name, fullpath in tree.dirs %}
44 <li><a href="{{ build_url('history', path=fullpath) }}" class=dir>{{ name|u }}</a></li>
66 <h2>
77 {{ filename|u }}
88 <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>
1010 (<a href="{{ raw_url }}">raw</a>
1111 &middot; <a href="{{ build_url('history', path=path) }}">history</a>)
1212 </span>