Check if current version is already latest. Returns true to skip update. */
| 11505 | |
| 11506 | /* Check if current version is already latest. Returns true to skip update. */ |
| 11507 | static bool check_already_latest(void) { |
| 11508 | char dl_env[CBM_SZ_256] = ""; |
| 11509 | cbm_safe_getenv("CBM_DOWNLOAD_URL", dl_env, sizeof(dl_env), NULL); |
| 11510 | if (dl_env[0]) { |
| 11511 | return false; /* testing override — always update */ |
| 11512 | } |
| 11513 | char *latest = fetch_latest_tag(); |
| 11514 | if (!latest) { |
| 11515 | (void)fprintf(stderr, "warning: could not check latest version (network unavailable?). " |
| 11516 | "Proceeding with update.\n"); |
| 11517 | return false; |
| 11518 | } |
| 11519 | int cmp = cbm_compare_versions(latest, CBM_VERSION); |
| 11520 | if (cmp <= 0) { |
| 11521 | if (cmp < 0) { |
| 11522 | printf("Already up to date (%s, ahead of latest %s).\n", CBM_VERSION, latest); |
| 11523 | } else { |
| 11524 | printf("Already up to date (%s).\n", CBM_VERSION); |
| 11525 | } |
| 11526 | free(latest); |
| 11527 | return true; |
| 11528 | } |
| 11529 | printf("Update available: %s -> %s\n", CBM_VERSION, latest); |
| 11530 | free(latest); |
| 11531 | return false; |
| 11532 | } |
| 11533 | |
| 11534 | #endif /* CBM_CLI_ENABLE_TEST_API */ |
| 11535 |
no test coverage detected