Fix update notice for versioned releases
Some checks failed
Release App / release-app (push) Has been cancelled
Some checks failed
Release App / release-app (push) Has been cancelled
This commit is contained in:
14
src/app.cpp
14
src/app.cpp
@@ -13,6 +13,13 @@ namespace telegram_tui {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string trim_release_tag_prefix(const std::string &value) {
|
||||
if (!value.empty() && (value[0] == 'v' || value[0] == 'V')) {
|
||||
return value.substr(1);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
bool is_truthy_env_value(const std::string &value) {
|
||||
return value == "1" || value == "true" || value == "TRUE" || value == "yes" ||
|
||||
value == "YES" || value == "on" || value == "ON";
|
||||
@@ -50,7 +57,7 @@ std::string run_command_capture(const std::string &command) {
|
||||
|
||||
std::optional<std::string> fetch_update_notice() {
|
||||
static constexpr const char *kLatestReleaseApiUrl =
|
||||
"https://git.mshq.dev/api/v1/repos/AxiFisk/shinoa/releases/tags/latest";
|
||||
"https://git.mshq.dev/api/v1/repos/AxiFisk/shinoa/releases/latest";
|
||||
|
||||
if (std::string(TELEGRAM_TUI_BUILD_COMMIT).empty()) {
|
||||
return std::nullopt;
|
||||
@@ -64,6 +71,11 @@ std::optional<std::string> fetch_update_notice() {
|
||||
|
||||
try {
|
||||
const json release = json::parse(response, nullptr, true, true);
|
||||
const std::string latest_tag = trim_release_tag_prefix(safe_string(release, "tag_name"));
|
||||
if (!latest_tag.empty() && latest_tag == TELEGRAM_TUI_PROJECT_VERSION) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const std::string target_commit = safe_string(release, "target_commitish");
|
||||
if (target_commit.empty()) {
|
||||
return std::nullopt;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define TELEGRAM_TUI_PROJECT_VERSION "@PROJECT_VERSION@"
|
||||
#define TELEGRAM_TUI_BUILD_COMMIT "@TELEGRAM_TUI_BUILD_COMMIT@"
|
||||
#define TELEGRAM_TUI_BUILD_VERSION "@TELEGRAM_TUI_BUILD_VERSION@"
|
||||
#define TELEGRAM_TUI_BUILD_API_ID "@TELEGRAM_TUI_BUILD_API_ID@"
|
||||
|
||||
Reference in New Issue
Block a user