Check if current version is already latest. Returns true to skip update. */
| 13621 | |
| 13622 | /* Check if current version is already latest. Returns true to skip update. */ |
| 13623 | static bool check_already_latest(void) { |
| 13624 | char dl_env[CBM_SZ_256] = ""; |
| 13625 | cbm_safe_getenv("CBM_DOWNLOAD_URL", dl_env, sizeof(dl_env), NULL); |
| 13626 | if (dl_env[0]) { |
| 13627 | return false; /* testing override — always update */ |
| 13628 | } |
| 13629 | char *latest = fetch_latest_tag(); |
| 13630 | if (!latest) { |
| 13631 | (void)fprintf(stderr, "warning: could not check latest version (network unavailable?). " |
| 13632 | "Proceeding with update.\n"); |
| 13633 | return false; |
| 13634 | } |
| 13635 | int cmp = cbm_compare_versions(latest, CBM_VERSION); |
| 13636 | if (cmp <= 0) { |
| 13637 | if (cmp < 0) { |
| 13638 | printf("Already up to date (%s, ahead of latest %s).\n", CBM_VERSION, latest); |
| 13639 | } else { |
| 13640 | printf("Already up to date (%s).\n", CBM_VERSION); |
| 13641 | } |
| 13642 | free(latest); |
| 13643 | return true; |
| 13644 | } |
| 13645 | printf("Update available: %s -> %s\n", CBM_VERSION, latest); |
| 13646 | free(latest); |
| 13647 | return false; |
| 13648 | } |
| 13649 | |
| 13650 | #endif /* CBM_CLI_ENABLE_TEST_API */ |
| 13651 |
no test coverage detected