feat(version): group version commands under yt version (YT-10) #54

Merged
David merged 1 commit from feat/version-command-YT-10 into main 2026-05-24 17:10:58 +02:00
Owner

Summary

Closes YT-10. Group all version-related surface under a single yt version namespace.

  • yt version (no subcommand) prints the same banner as yt --version.
  • yt version check does a HEAD against the Generic Package registry and reports whether a newer build is available, without downloading.
  • yt version update replaces the running binary (the old top-level yt update, identical flags --url, --dry-run, --force).
  • yt update is removed; clap returns its standard "unrecognized subcommand" error.
  • Clap's --version / -V continue to work unchanged.

Implementation notes

src/commands/update.rs was split into src/commands/version/{mod.rs, check.rs, update.rs}. The freshness probe (HEAD + Last-Modified parse + comparison against the baked YOUTRACK_CLI_BUILD_DATE) moved into a shared fetch_remote_freshness helper in mod.rs that returns a RemoteFreshness { remote_last_modified, baked_build_date, remote_is_newer } so both check and update can render or short-circuit off the same data.

The existing update tests moved with the code; check_writable_returns_friendly_message_on_readonly_dir switched its root-detection from $USER == "root" to probing the actual check_writable result, because the rust-builder docker image used by just pre-commit does not propagate $USER and the test was failing on main for that reason.

Doc strings referencing the old command surface were updated to yt version update: build.rs, oci-build/Dockerfile, oci-build/Dockerfile.windows, the two Forgejo build-*.yml workflows, and the CLAUDE.md status line.

Out-of-scope but bundled

Two pre-existing rustfmt drifts in src/commands/article/{create,pull}.rs are included so cargo fmt --check (and therefore just pre-commit) is green. They are pure formatting; no logic change.

Test plan

  • cargo test --all-targets (286 unit + 3 integration tests pass).
  • just pre-commit (fmt, clippy, build, test inside rust-builder-musl docker) is green.
  • yt --version and yt -V print the version banner.
  • yt version prints the same banner.
  • yt help version lists show, check, update.
  • yt version update --help shows the same --url, --dry-run, --force flags as the old yt update.
  • yt update returns clap's "unrecognized subcommand 'update'" error.
## Summary Closes [YT-10](https://niceguyit.myjetbrains.com/issue/YT-10). Group all version-related surface under a single `yt version` namespace. - `yt version` (no subcommand) prints the same banner as `yt --version`. - `yt version check` does a HEAD against the Generic Package registry and reports whether a newer build is available, without downloading. - `yt version update` replaces the running binary (the old top-level `yt update`, identical flags `--url`, `--dry-run`, `--force`). - `yt update` is removed; clap returns its standard "unrecognized subcommand" error. - Clap's `--version` / `-V` continue to work unchanged. ## Implementation notes `src/commands/update.rs` was split into `src/commands/version/{mod.rs, check.rs, update.rs}`. The freshness probe (`HEAD` + `Last-Modified` parse + comparison against the baked `YOUTRACK_CLI_BUILD_DATE`) moved into a shared `fetch_remote_freshness` helper in `mod.rs` that returns a `RemoteFreshness { remote_last_modified, baked_build_date, remote_is_newer }` so both `check` and `update` can render or short-circuit off the same data. The existing update tests moved with the code; `check_writable_returns_friendly_message_on_readonly_dir` switched its root-detection from `$USER == "root"` to probing the actual `check_writable` result, because the rust-builder docker image used by `just pre-commit` does not propagate `$USER` and the test was failing on `main` for that reason. Doc strings referencing the old command surface were updated to `yt version update`: `build.rs`, `oci-build/Dockerfile`, `oci-build/Dockerfile.windows`, the two Forgejo `build-*.yml` workflows, and the `CLAUDE.md` status line. ## Out-of-scope but bundled Two pre-existing rustfmt drifts in `src/commands/article/{create,pull}.rs` are included so `cargo fmt --check` (and therefore `just pre-commit`) is green. They are pure formatting; no logic change. ## Test plan - [x] `cargo test --all-targets` (286 unit + 3 integration tests pass). - [x] `just pre-commit` (fmt, clippy, build, test inside rust-builder-musl docker) is green. - [x] `yt --version` and `yt -V` print the version banner. - [x] `yt version` prints the same banner. - [x] `yt help version` lists `show`, `check`, `update`. - [x] `yt version update --help` shows the same `--url`, `--dry-run`, `--force` flags as the old `yt update`. - [x] `yt update` returns clap's "unrecognized subcommand 'update'" error.
feat(version): group version commands under yt version (YT-10)
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 16s
Create release / Create release from merged PR (pull_request) Has been skipped
c6a21cfe1c
Replace the top-level `yt update` subcommand with a `yt version` namespace that bundles three subcommands: `show` (default, prints the same banner as `yt --version`), `check` (HEAD-only registry freshness probe), and `update` (the existing self-replace flow, unchanged externally). Clap's `--version` / `-V` flags continue to work.

The freshness logic moved into a shared `fetch_remote_freshness` helper in `commands/version/mod.rs` that returns the remote `Last-Modified`, the baked build date, and a precomputed `remote_is_newer` flag. Both `check` and `update` consume it: `update` short-circuits when the remote is not newer, `check` renders a one-liner without ever touching the binary.

Module layout: `src/commands/update.rs` is split into `src/commands/version/{mod.rs, check.rs, update.rs}`. The existing update tests move with the code unchanged in behavior; the `check_writable_returns_friendly_message_on_readonly_dir` test now detects root by probing for an `Ok(())` from the readonly write instead of relying on the `USER` env var (which is unset inside the rust-builder docker image, causing the test to fail there on `main`).

Doc references to `yt update` (build.rs, oci-build Dockerfiles, build-linux / build-windows workflow comments, CLAUDE.md status line) are rewritten to `yt version update`. Two unrelated rustfmt drifts in `src/commands/article/{create,pull}.rs` are picked up so `cargo fmt --check` is green.

#YT-10 State Done
David merged commit a2b400e4e9 into main 2026-05-24 17:10:58 +02:00
David deleted branch feat/version-command-YT-10 2026-05-24 17:10:58 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pandoras-box/youtrack-cli!54
No description provided.