Check if current version is already latest. Returns true to skip update. */
| 12116 | |
| 12117 | /* Check if current version is already latest. Returns true to skip update. */ |
| 12118 | static bool check_already_latest(void) { |
| 12119 | char dl_env[CBM_SZ_256] = ""; |
| 12120 | cbm_safe_getenv("CBM_DOWNLOAD_URL", dl_env, sizeof(dl_env), NULL); |
| 12121 | if (dl_env[0]) { |
| 12122 | return false; /* testing override — always update */ |
| 12123 | } |
| 12124 | char *latest = fetch_latest_tag(); |
| 12125 | if (!latest) { |
| 12126 | (void)fprintf(stderr, "warning: could not check latest version (network unavailable?). " |
| 12127 | "Proceeding with update.\n"); |
| 12128 | return false; |
| 12129 | } |
| 12130 | int cmp = cbm_compare_versions(latest, CBM_VERSION); |
| 12131 | if (cmp <= 0) { |
| 12132 | if (cmp < 0) { |
| 12133 | printf("Already up to date (%s, ahead of latest %s).\n", CBM_VERSION, latest); |
| 12134 | } else { |
| 12135 | printf("Already up to date (%s).\n", CBM_VERSION); |
| 12136 | } |
| 12137 | free(latest); |
| 12138 | return true; |
| 12139 | } |
| 12140 | printf("Update available: %s -> %s\n", CBM_VERSION, latest); |
| 12141 | free(latest); |
| 12142 | return false; |
| 12143 | } |
| 12144 | |
| 12145 | #endif /* CBM_CLI_ENABLE_TEST_API */ |
| 12146 |
no test coverage detected