1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
From c73f413c6696f5ad6f5429eeebe465a6bc9fdd25 Mon Sep 17 00:00:00 2001
From: Malfurious <m@lfurio.us>
Date: Tue, 21 Nov 2023 05:44:42 -0500
Subject: [PATCH] patch: colorfulhashes
Color unique git hashes when they appear in DMT to aid recognition.
This makes it easier to spot hash values that match, even if they appear
under different service entries. Committer identities are also colored
for the same reason.
Colors are derived directly from the hash value. The first 6 characters
of the hash are interpreted as the RGB color value.
---
dmt/html/services.html | 14 ++++++++++----
dmt/script.js | 3 ++-
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/dmt/html/services.html b/dmt/html/services.html
index ae4dee6..0bc7b0a 100644
--- a/dmt/html/services.html
+++ b/dmt/html/services.html
@@ -25,22 +25,28 @@
<table>
<tr>
<td>Deployed:</td>
- <td>%($previous_hash%)</td>
+ %{ col_previous_hash=$(echo "$previous_hash" | head -c6) %}
+ <td style="color: #%($col_previous_hash%);">%($previous_hash%)</td>
<td>%{describe $previous_hash%}</td>
</tr>
<tr>
<td>Commit:</td>
- <td>%($current_hash%)</td>
+ %{ col_current_hash=$(echo "$current_hash" | head -c6) %}
+ <td style="color: #%($col_current_hash%);">%($current_hash%)</td>
<td>%{describe $current_hash%}</td>
</tr>
<tr>
<td>Committer:</td>
- <td>%{show '%cn <%ce>'%}</td>
+ %{ comm_id=$(show '%cn <%ce>') %}
+ %{ col_comm_id=$(echo "$comm_id" | sha1sum | head -c6) %}
+ <td style="color: #%($col_comm_id%);">%($comm_id%)</td>
<td>%{show '%cD'%}</td>
</tr>
<tr>
<td>Tree:</td>
- <td>%{show '%T'%}</td>
+ %{ tree_hash=$(show '%T') %}
+ %{ col_tree_hash=$(echo "$tree_hash" | head -c6) %}
+ <td style="color: #%($col_tree_hash%);">%($tree_hash%)</td>
</tr>
</table>
</div>
diff --git a/dmt/script.js b/dmt/script.js
index bc9554c..6996978 100644
--- a/dmt/script.js
+++ b/dmt/script.js
@@ -47,6 +47,7 @@ function touch_job(list, job) {
// New job, new <div>
if (document.getElementById(`${job.job}`) === null) {
let abv_hash = job.hash.substring(0, 16);
+ let col_hash = job.hash.substring(0, 6);
let reason = (job.reason == "event" ? ICON_EVENT : ICON_MAINT);
let element = document.createElement("div");
@@ -60,7 +61,7 @@ function touch_job(list, job) {
</a>
#${job.job}
${job.service}
- <small><i>${abv_hash}</i></small>
+ <small style="color: #${col_hash};"><i>${abv_hash}</i></small>
<span class="right">
<span class="time" id="${job.job}_time"
--
2.42.0
|