Check if current version is already latest. Returns true to skip update. */
| 11472 | |
| 11473 | /* Check if current version is already latest. Returns true to skip update. */ |
| 11474 | static bool check_already_latest(void) { |
| 11475 | char dl_env[CBM_SZ_256] = ""; |
| 11476 | cbm_safe_getenv("CBM_DOWNLOAD_URL", dl_env, sizeof(dl_env), NULL); |
| 11477 | if (dl_env[0]) { |
| 11478 | return false; /* testing override — always update */ |
| 11479 | } |
| 11480 | char *latest = fetch_latest_tag(); |
| 11481 | if (!latest) { |
| 11482 | (void)fprintf(stderr, "warning: could not check latest version (network unavailable?). " |
| 11483 | "Proceeding with update.\n"); |
| 11484 | return false; |
| 11485 | } |
| 11486 | int cmp = cbm_compare_versions(latest, CBM_VERSION); |
| 11487 | if (cmp <= 0) { |
| 11488 | if (cmp < 0) { |
| 11489 | printf("Already up to date (%s, ahead of latest %s).\n", CBM_VERSION, latest); |
| 11490 | } else { |
| 11491 | printf("Already up to date (%s).\n", CBM_VERSION); |
| 11492 | } |
| 11493 | free(latest); |
| 11494 | return true; |
| 11495 | } |
| 11496 | printf("Update available: %s -> %s\n", CBM_VERSION, latest); |
| 11497 | free(latest); |
| 11498 | return false; |
| 11499 | } |
| 11500 | |
| 11501 | #endif /* CBM_CLI_ENABLE_TEST_API */ |
| 11502 |
no test coverage detected