mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
fix: Update nightly update detection logic to work with release changes
This commit is contained in:
@@ -133,6 +133,9 @@ endif ()
|
||||
|
||||
addDefineToSource(source/api/imhex_api.cpp "IMHEX_VERSION=\"${IMHEX_VERSION_STRING}\"")
|
||||
|
||||
string(TIMESTAMP IMHEX_BUILD_DATE UTC)
|
||||
addDefineToSource(source/api/imhex_api.cpp "IMHEX_BUILD_DATE=\"${IMHEX_BUILD_DATE}\"")
|
||||
|
||||
enableUnityBuild(libimhex)
|
||||
setupCompilerFlags(libimhex)
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/fs.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
@@ -654,6 +655,12 @@ EXPORT_MODULE namespace hex {
|
||||
*/
|
||||
std::string getCommitBranch();
|
||||
|
||||
/**
|
||||
* @brief Gets the time ImHex was built
|
||||
* @return The time ImHex was built
|
||||
*/
|
||||
std::optional<std::chrono::system_clock::time_point> getBuildTime();
|
||||
|
||||
/**
|
||||
* @brief Checks if ImHex was built in debug mode
|
||||
* @return True if ImHex was built in debug mode, false otherwise
|
||||
|
||||
@@ -883,7 +883,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
SemanticVersion getImHexVersion() {
|
||||
#if defined IMHEX_VERSION
|
||||
#if defined(IMHEX_VERSION)
|
||||
static auto version = SemanticVersion(IMHEX_VERSION);
|
||||
return version;
|
||||
#else
|
||||
@@ -892,7 +892,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
std::string getCommitHash(bool longHash) {
|
||||
#if defined GIT_COMMIT_HASH_LONG
|
||||
#if defined(GIT_COMMIT_HASH_LONG)
|
||||
if (longHash) {
|
||||
return GIT_COMMIT_HASH_LONG;
|
||||
} else {
|
||||
@@ -905,13 +905,21 @@ namespace hex {
|
||||
}
|
||||
|
||||
std::string getCommitBranch() {
|
||||
#if defined GIT_BRANCH
|
||||
#if defined(GIT_BRANCH)
|
||||
return GIT_BRANCH;
|
||||
#else
|
||||
return "Unknown";
|
||||
#endif
|
||||
}
|
||||
|
||||
std::optional<std::chrono::system_clock::time_point> getBuildTime() {
|
||||
#if defined(IMHEX_BUILD_DATE)
|
||||
return hex::parseTime("%Y-%m-%dT%H:%M:%SZ", IMHEX_BUILD_DATE);
|
||||
#else
|
||||
return std::nullopt;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool isDebugBuild() {
|
||||
#if defined DEBUG
|
||||
return true;
|
||||
|
||||
@@ -51,11 +51,16 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
// Check if the response is valid
|
||||
if (!releases.contains("published_at") || !releases["published_at"].is_string())
|
||||
if (!releases.contains("assets") || !releases["assets"].is_array())
|
||||
return;
|
||||
|
||||
const auto nightlyUpdateTime = hex::parseTime("%FT%TZ", releases["published_at"].get<std::string>());
|
||||
if (nightlyUpdateTime.has_value() && *nightlyUpdateTime > std::chrono::system_clock::now()) {
|
||||
const auto firstAsset = releases["assets"].front();
|
||||
if (!firstAsset.is_object() || !firstAsset.contains("updated_at"))
|
||||
return;
|
||||
|
||||
const auto nightlyUpdateTime = hex::parseTime("%Y-%m-%dT%H:%M:%SZ", firstAsset["updated_at"].get<std::string>());
|
||||
const auto imhexBuildTime = ImHexApi::System::getBuildTime();
|
||||
if (nightlyUpdateTime.has_value() && imhexBuildTime.has_value() && *nightlyUpdateTime > *imhexBuildTime) {
|
||||
updateString = "Nightly";
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user