fix #362 system Info checks git head, instead of build branch (#374)

This commit is contained in:
helgeerbe 2023-08-09 17:45:54 +02:00 committed by GitHub
parent 21bbed9b8e
commit 5a72d74982
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 2 deletions

View File

@ -18,10 +18,14 @@ from dulwich import porcelain
def get_firmware_specifier_build_flag(): def get_firmware_specifier_build_flag():
try: try:
build_version = porcelain.describe('.') # '.' refers to the repository root dir build_version = porcelain.describe('.') # '.' refers to the repository root dir
branch_name = porcelain.active_branch('.').decode('utf-8')
except: except:
build_version = "g0000000" build_version = "g0000000"
build_flag = "-D AUTO_GIT_HASH=\\\"" + build_version + "\\\"" branch_name = ""
build_flag = "-D AUTO_GIT_HASH=\\\"" + build_version + "\\\" "
build_flag += "-D AUTO_GIT_BRANCH=\\\"" + branch_name + "\\\""
print ("Firmware Revision: " + build_version) print ("Firmware Revision: " + build_version)
print ("Firmware build on branch: " + branch_name)
return (build_flag) return (build_flag)
env.Append( env.Append(

View File

@ -16,6 +16,10 @@
#define AUTO_GIT_HASH "" #define AUTO_GIT_HASH ""
#endif #endif
#ifndef AUTO_GIT_BRANCH
#define AUTO_GIT_BRANCH ""
#endif
void WebApiSysstatusClass::init(AsyncWebServer* server) void WebApiSysstatusClass::init(AsyncWebServer* server)
{ {
using std::placeholders::_1; using std::placeholders::_1;
@ -67,6 +71,7 @@ void WebApiSysstatusClass::onSystemStatus(AsyncWebServerRequest* request)
snprintf(version, sizeof(version), "%d.%d.%d", CONFIG_VERSION >> 24 & 0xff, CONFIG_VERSION >> 16 & 0xff, CONFIG_VERSION >> 8 & 0xff); snprintf(version, sizeof(version), "%d.%d.%d", CONFIG_VERSION >> 24 & 0xff, CONFIG_VERSION >> 16 & 0xff, CONFIG_VERSION >> 8 & 0xff);
root["config_version"] = version; root["config_version"] = version;
root["git_hash"] = AUTO_GIT_HASH; root["git_hash"] = AUTO_GIT_HASH;
root["git_branch"] = AUTO_GIT_BRANCH;
root["pioenv"] = PIOENV; root["pioenv"] = PIOENV;
root["uptime"] = esp_timer_get_time() / 1000000; root["uptime"] = esp_timer_get_time() / 1000000;

View File

@ -22,6 +22,10 @@
{{ systemStatus.git_hash }} {{ systemStatus.git_hash }}
</a></td> </a></td>
</tr> </tr>
<tr>
<th>{{ $t('firmwareinfo.FirmwareBranch') }}</th>
<td>{{ systemStatus.git_branch }}</td>
</tr>
<tr> <tr>
<th>{{ $t('firmwareinfo.PioEnv') }}</th> <th>{{ $t('firmwareinfo.PioEnv') }}</th>
<td>{{ systemStatus.pioenv }}</td> <td>{{ systemStatus.pioenv }}</td>

View File

@ -202,6 +202,7 @@
"SdkVersion": "SDK Version", "SdkVersion": "SDK Version",
"ConfigVersion": "Config Version", "ConfigVersion": "Config Version",
"FirmwareVersion": "Firmware Version / Git Hash", "FirmwareVersion": "Firmware Version / Git Hash",
"FirmwareBranch": "Firmware Branch",
"PioEnv": "PIO Environment", "PioEnv": "PIO Environment",
"FirmwareVersionHint": "Click here to show information about your current version", "FirmwareVersionHint": "Click here to show information about your current version",
"FirmwareUpdate": "Firmware Update", "FirmwareUpdate": "Firmware Update",

View File

@ -10,6 +10,7 @@ export interface SystemStatus {
config_version: string; config_version: string;
git_hash: string; git_hash: string;
git_is_hash: boolean; git_is_hash: boolean;
git_branch: string;
pioenv: string; pioenv: string;
resetreason_0: string; resetreason_0: string;
resetreason_1: string; resetreason_1: string;

View File

@ -61,7 +61,7 @@ export default defineComponent({
} }
const fetchUrl = "https://api.github.com/repos/helgeerbe/OpenDTU-OnBattery/compare/" const fetchUrl = "https://api.github.com/repos/helgeerbe/OpenDTU-OnBattery/compare/"
+ this.systemDataList.git_hash + "...HEAD"; + this.systemDataList.git_hash + "..." + this.systemDataList.git_branch;
fetch(fetchUrl) fetch(fetchUrl)
.then((response) => { .then((response) => {

Binary file not shown.