Check if current version is already latest. Returns true to skip update. */
| 11858 | |
| 11859 | /* Check if current version is already latest. Returns true to skip update. */ |
| 11860 | static bool check_already_latest(void) { |
| 11861 | char dl_env[CBM_SZ_256] = ""; |
| 11862 | cbm_safe_getenv("CBM_DOWNLOAD_URL", dl_env, sizeof(dl_env), NULL); |
| 11863 | if (dl_env[0]) { |
| 11864 | return false; /* testing override — always update */ |
| 11865 | } |
| 11866 | char *latest = fetch_latest_tag(); |
| 11867 | if (!latest) { |
| 11868 | (void)fprintf(stderr, "warning: could not check latest version (network unavailable?). " |
| 11869 | "Proceeding with update.\n"); |
| 11870 | return false; |
| 11871 | } |
| 11872 | int cmp = cbm_compare_versions(latest, CBM_VERSION); |
| 11873 | if (cmp <= 0) { |
| 11874 | if (cmp < 0) { |
| 11875 | printf("Already up to date (%s, ahead of latest %s).\n", CBM_VERSION, latest); |
| 11876 | } else { |
| 11877 | printf("Already up to date (%s).\n", CBM_VERSION); |
| 11878 | } |
| 11879 | free(latest); |
| 11880 | return true; |
| 11881 | } |
| 11882 | printf("Update available: %s -> %s\n", CBM_VERSION, latest); |
| 11883 | free(latest); |
| 11884 | return false; |
| 11885 | } |
| 11886 | |
| 11887 | #endif /* CBM_CLI_ENABLE_TEST_API */ |
| 11888 |
no test coverage detected