Check if current version is already latest. Returns true to skip update. */
| 11449 | |
| 11450 | /* Check if current version is already latest. Returns true to skip update. */ |
| 11451 | static bool check_already_latest(void) { |
| 11452 | char dl_env[CBM_SZ_256] = ""; |
| 11453 | cbm_safe_getenv("CBM_DOWNLOAD_URL", dl_env, sizeof(dl_env), NULL); |
| 11454 | if (dl_env[0]) { |
| 11455 | return false; /* testing override — always update */ |
| 11456 | } |
| 11457 | char *latest = fetch_latest_tag(); |
| 11458 | if (!latest) { |
| 11459 | (void)fprintf(stderr, "warning: could not check latest version (network unavailable?). " |
| 11460 | "Proceeding with update.\n"); |
| 11461 | return false; |
| 11462 | } |
| 11463 | int cmp = cbm_compare_versions(latest, CBM_VERSION); |
| 11464 | if (cmp <= 0) { |
| 11465 | if (cmp < 0) { |
| 11466 | printf("Already up to date (%s, ahead of latest %s).\n", CBM_VERSION, latest); |
| 11467 | } else { |
| 11468 | printf("Already up to date (%s).\n", CBM_VERSION); |
| 11469 | } |
| 11470 | free(latest); |
| 11471 | return true; |
| 11472 | } |
| 11473 | printf("Update available: %s -> %s\n", CBM_VERSION, latest); |
| 11474 | free(latest); |
| 11475 | return false; |
| 11476 | } |
| 11477 | |
| 11478 | #endif /* CBM_CLI_ENABLE_TEST_API */ |
| 11479 |
no test coverage detected