diff --git a/.gitignore b/.gitignore
index 4e36d045..d666e6af 100644
--- a/.gitignore
+++ b/.gitignore
@@ -137,3 +137,6 @@ dmypy.json
# Cython debug symbols
cython_debug/
+
+# VSCode editor related stuff
+.vscode/
diff --git a/hw_diag/diagnostics/env_var_diagnostics.py b/hw_diag/diagnostics/env_var_diagnostics.py
index c6f37532..30eb273b 100644
--- a/hw_diag/diagnostics/env_var_diagnostics.py
+++ b/hw_diag/diagnostics/env_var_diagnostics.py
@@ -19,6 +19,9 @@
}, {
'ENV_VAR': 'VARIANT',
'DIAGNOSTIC_KEY': 'VA'
+}, {
+ 'ENV_VAR': 'FIRMWARE_SHORT_HASH',
+ 'DIAGNOSTIC_KEY': 'firmware_short_hash'
}]
diff --git a/hw_diag/templates/diagnostics_page.html b/hw_diag/templates/diagnostics_page.html
index ee5bd92f..637a8feb 100644
--- a/hw_diag/templates/diagnostics_page.html
+++ b/hw_diag/templates/diagnostics_page.html
@@ -83,7 +83,7 @@
Diagnostics Breakdown
Firmware Version |
- {{ diagnostics.FW }} |
+ {{ diagnostics.FW }} ({{ diagnostics.firmware_short_hash }}) |
Frequency |
diff --git a/hw_diag/tests/diagnostics/test_env_var_diagnostics.py b/hw_diag/tests/diagnostics/test_env_var_diagnostics.py
index 15e62f5a..574a10a2 100644
--- a/hw_diag/tests/diagnostics/test_env_var_diagnostics.py
+++ b/hw_diag/tests/diagnostics/test_env_var_diagnostics.py
@@ -56,5 +56,10 @@ def test_env_vars_success(self):
'FIRMWARE_VERSION': 'foo',
'FW': 'foo',
'VARIANT': 'foo',
- 'VA': 'foo'
+ 'VA': 'foo',
+ # We're moving towards longer lowercase key naming and will
+ # deprecate old ones in near future. Just keeping this entry in the
+ # list for the sake of style compatibility.
+ 'FIRMWARE_SHORT_HASH': 'foo',
+ 'firmware_short_hash': 'foo'
})
diff --git a/hw_diag/tests/test_views_diagnostics.py b/hw_diag/tests/test_views_diagnostics.py
index f5a61b91..5d78b02d 100644
--- a/hw_diag/tests/test_views_diagnostics.py
+++ b/hw_diag/tests/test_views_diagnostics.py
@@ -71,7 +71,11 @@ def test_initFile_output(self):
@patch.dict(
os.environ,
- {'FIRMWARE_VERSION': '1337.13.37', 'DIAGNOSTICS_VERSION': 'aabbffe'}
+ {
+ 'FIRMWARE_VERSION': '1337.13.37',
+ 'DIAGNOSTICS_VERSION': 'aabbffe',
+ 'FIRMWARE_SHORT_HASH': '0011223'
+ }
)
def test_version_endpoint(self):
# Check the version json output
@@ -81,3 +85,4 @@ def test_version_endpoint(self):
self.assertEqual(resp.status_code, 200)
self.assertEqual(reply['firmware_version'], '1337.13.37')
self.assertEqual(reply['diagnostics_version'], 'aabbffe')
+ self.assertEqual(reply['firmware_short_hash'], '0011223')
diff --git a/hw_diag/utilities/shell.py b/hw_diag/utilities/shell.py
index 933a9366..f01d949c 100644
--- a/hw_diag/utilities/shell.py
+++ b/hw_diag/utilities/shell.py
@@ -13,9 +13,10 @@ def get_environment_var(diagnostics):
'BALENA_APP_NAME',
'FREQ',
'FIRMWARE_VERSION',
- 'VARIANT'
+ 'VARIANT',
+ 'FIRMWARE_SHORT_HASH'
]
- keys = ["BN", "ID", "BA", "FR", "FW", "VA"]
+ keys = ["BN", "ID", "BA", "FR", "FW", "VA", "firmware_short_hash"]
for (var, key) in zip(env_var, keys):
diagnostics[key] = os.getenv(var)
diff --git a/hw_diag/views/diagnostics.py b/hw_diag/views/diagnostics.py
index 41594368..e961c5e7 100644
--- a/hw_diag/views/diagnostics.py
+++ b/hw_diag/views/diagnostics.py
@@ -107,6 +107,7 @@ def version_information():
response = {
'firmware_version': os.getenv('FIRMWARE_VERSION', 'unknown'),
'diagnostics_version': os.getenv('DIAGNOSTICS_VERSION', 'unknown'),
+ 'firmware_short_hash': os.getenv('FIRMWARE_SHORT_HASH', 'unknown'),
}
return response