feat: implement issue inspect and issue sprint show (PR 3/5) #14
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/issue-inspect-and-sprint-show"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
PR 3 of 5. Ports the two read-only single-issue commands.
issue inspect <id>: primaryGET /api/issues/<id>plus four sub-fetches (comments, work items, sprints, links). Sub-fetch failures are non-fatal and collected intowarnings, matching Go. Output sections:ID: summary,Fields:,Sprints:,Recent comments:(last 5),Recent work items:(last 5),Links:,Warnings:(only when non-empty). Work-item duration falls back to humanized minutes when YouTrack returns an emptypresentation.--jsonemits the fullIssueInspectstruct.issue sprint show <id>: marker-list (* <name> [current]) of every sprint the issue belongs to, with--jsonfor the raw array.New shared infrastructure
yt::duration::humanize_duration: 1d = 6h convention, identical to Go'sHumanizeDuration. Returns"1h 15m"style strings; zero ->"0m".yt::output::{format_millis, compact_text, author_name, tail}: timestamp formatting (UTCYYYY-MM-DD HH:MM), whitespace-collapsing truncation with ellipsis, author display ladder (fullName->login->unknown), and slice tail helper.Author,IssueComment,WorkItem/WorkDuration,IssueLink/IssueLinkType, aggregateIssueInspect.inspect_issue(composes the five fetches and surfaces warnings) andlist_issue_sprints.Verification
cargo fmt --checkclean.cargo clippy --all-targets -- -D warningsclean.cargo test --all-targets: 85 tests pass (27 new on this branch).Coverage on this PR: full happy-path wiremock test for inspect, all-subfetches-failed (asserts 4 warnings in fixed order, every section empty), primary 404 propagation, missing-credentials guard, empty/non-empty/JSON paths for sprint show, link-label fallback ladder,
humanize_durationzero / day-rollover / day+hours-no-minutes, plus existing helper coverage.Test plan
youtrack-cli issue inspect <ID>against a real instance. Confirm: fields render, last 5 comments / work items shown, links labeled with localized name where present.Warnings: - comments: ...block at the bottom.youtrack-cli issue inspect <ID> --json | jqproduces a parseable object.youtrack-cli issue sprint show <ID>prints* <name> [current]for the active sprint and<name>for inactive ones, or(none)for an issue with no sprints.PR 3 of 5. Ports the two read-only single-issue commands. `issue inspect` makes the primary GET on the issue plus four sub-fetches (comments, work items, sprints, links). Sub-fetch failures are non-fatal and collected as warnings, matching the Go CLI; only the primary issue request causes the command to abort. The output mirrors Go's sections (ID:Summary, Fields, Sprints, Recent comments (last 5), Recent work items (last 5), Links, Warnings), with `--json` falling back to a pretty-printed `IssueInspect` struct. Work-item duration falls back to humanized minutes when the YouTrack response leaves `presentation` empty, again matching Go. `issue sprint show` prints the marker list `* <name> [current]` for a single issue, with `--json` for the raw sprint array. New shared infrastructure: `yt::duration::humanize_duration` (1d = 6h convention, identical to Go's `HumanizeDuration`); `yt::output::{format_millis, compact_text, author_name, tail}` for the inspect rendering; `Author`, `IssueComment`, `WorkItem`/`WorkDuration`, `IssueLink`/`IssueLinkType`, and `IssueInspect` models. New api helpers `inspect_issue` and `list_issue_sprints`. Tests cover both end-to-end paths via wiremock (full happy path, all-subfetches-failed warnings collection, primary 404 propagation, missing-credentials guard, empty sprint list, JSON mode), pure-function tests for the new output helpers (format_millis edge cases, compact_text truncation, author_name fallback ladder, tail), pure unit tests for the link-label selector, plus the new humanize_duration cases (zero, day-rollover, day+hours-no-minutes). 85 tests pass; clippy clean; fmt clean.