Display only first 7 chars for git commit id

On the status page, if a job was queued via a timer or some way
other than a gerrit change id, the git commit id would be too long
for the change box. Limit it to 7 chars.

Co-Authored-By: Sergey Lukjanov <slukjanov@mirantis.com>
Change-Id: I4f54845675d11e4f76240cf4bf7b48f28f3e7d6a
This commit is contained in:
Joshua Hesketh 2014-08-21 11:32:44 +10:00
parent a95fd55db9
commit cd7a0778e2
1 changed files with 15 additions and 3 deletions

View File

@ -267,9 +267,21 @@
var $change_link = $('<small />');
if (change.url !== null) {
$change_link.append(
$('<a />').attr('href', change.url).text(change.id)
);
if (/^[0-9a-f]{40}$/.test(change.id)) {
var change_id_short = change.id.slice(0, 7);
$change_link.append(
$('<a />').attr('href', change.url).append(
$('<abbr />')
.attr('title', change.id)
.text(change_id_short)
)
);
}
else {
$change_link.append(
$('<a />').attr('href', change.url).text(change.id)
);
}
}
else {
$change_link.text(change_id);