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
diff --git a/etc/status/public_html/jquery.zuul.js b/etc/status/public_html/jquery.zuul.js
index 7e5f640..5d155af 100644
--- a/etc/status/public_html/jquery.zuul.js
+++ b/etc/status/public_html/jquery.zuul.js
@@ -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);