Check if current version is already latest. Returns true to skip update. */
| 4352 | |
| 4353 | /* Check if current version is already latest. Returns true to skip update. */ |
| 4354 | static bool check_already_latest(void) { |
| 4355 | char dl_env[CBM_SZ_256] = ""; |
| 4356 | cbm_safe_getenv("CBM_DOWNLOAD_URL", dl_env, sizeof(dl_env), NULL); |
| 4357 | if (dl_env[0]) { |
| 4358 | return false; /* testing override — always update */ |
| 4359 | } |
| 4360 | char *latest = fetch_latest_tag(); |
| 4361 | if (!latest) { |
| 4362 | (void)fprintf(stderr, "warning: could not check latest version (network unavailable?). " |
| 4363 | "Proceeding with update.\n"); |
| 4364 | return false; |
| 4365 | } |
| 4366 | int cmp = cbm_compare_versions(latest, CBM_VERSION); |
| 4367 | if (cmp <= 0) { |
| 4368 | if (cmp < 0) { |
| 4369 | printf("Already up to date (%s, ahead of latest %s).\n", CBM_VERSION, latest); |
| 4370 | } else { |
| 4371 | printf("Already up to date (%s).\n", CBM_VERSION); |
| 4372 | } |
| 4373 | free(latest); |
| 4374 | return true; |
| 4375 | } |
| 4376 | printf("Update available: %s -> %s\n", CBM_VERSION, latest); |
| 4377 | free(latest); |
| 4378 | return false; |
| 4379 | } |
| 4380 | |
| 4381 | int cbm_cmd_update(int argc, char **argv) { |
| 4382 | parse_auto_answer(argc, argv); |
no test coverage detected