Check if current version is already latest. Returns true to skip update. */
| 11428 | |
| 11429 | /* Check if current version is already latest. Returns true to skip update. */ |
| 11430 | static bool check_already_latest(void) { |
| 11431 | char dl_env[CBM_SZ_256] = ""; |
| 11432 | cbm_safe_getenv("CBM_DOWNLOAD_URL", dl_env, sizeof(dl_env), NULL); |
| 11433 | if (dl_env[0]) { |
| 11434 | return false; /* testing override — always update */ |
| 11435 | } |
| 11436 | char *latest = fetch_latest_tag(); |
| 11437 | if (!latest) { |
| 11438 | (void)fprintf(stderr, "warning: could not check latest version (network unavailable?). " |
| 11439 | "Proceeding with update.\n"); |
| 11440 | return false; |
| 11441 | } |
| 11442 | int cmp = cbm_compare_versions(latest, CBM_VERSION); |
| 11443 | if (cmp <= 0) { |
| 11444 | if (cmp < 0) { |
| 11445 | printf("Already up to date (%s, ahead of latest %s).\n", CBM_VERSION, latest); |
| 11446 | } else { |
| 11447 | printf("Already up to date (%s).\n", CBM_VERSION); |
| 11448 | } |
| 11449 | free(latest); |
| 11450 | return true; |
| 11451 | } |
| 11452 | printf("Update available: %s -> %s\n", CBM_VERSION, latest); |
| 11453 | free(latest); |
| 11454 | return false; |
| 11455 | } |
| 11456 | |
| 11457 | #endif /* CBM_CLI_ENABLE_TEST_API */ |
| 11458 |
no test coverage detected