feat(sprint): add yt sprint create and yt sprint update (YT-2) #48
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/sprint-create-update"
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
Adds the two sprint-management commands that were still open on YT-2 after the null-date crash fix landed in #45. This PR closes YT-2 entirely.
yt sprint create --name <SPRINT> [--board <BOARD>] [--start YYYY-MM-DD] [--finish YYYY-MM-DD] [--json]posts to/api/agiles/<board>/sprintswith a JSON body containing the supplied fields. Dates are optional; YouTrack accepts a sprint with no schedule.--boardfalls back to theboardconfig value, matching the existingsprint list/sprint currentergonomics.yt sprint update <SPRINT> [--board <BOARD>] [--name <NEW_NAME>] [--start YYYY-MM-DD] [--finish YYYY-MM-DD] [--json]resolves the sprint by name on the board and POSTs to/api/agiles/<board>/sprints/<id>with a PARTIAL body containing only the fields the caller supplied. Unset flags do not clobber existing values. Errors loudly if no field is supplied or the sprint name is not on the board. YouTrack uses POST for partial sprint updates, not PUT or PATCH.YouTrack
YT-2 (closes; items 2 and 3 of 3; item 1 was the null-date fix in #45)
What got added / refactored
src/cli.rs:SprintCommands::Create(SprintCreateArgs)andSprintCommands::Update(SprintUpdateArgs)variants plus their args structs.src/yt/api.rs:create_sprint(...)andupdate_sprint(...)functions, newApiError::SprintNotFound(name, board)variant, smallresolve_board(client, board_name)helper factored out oflist_sprintsso both new commands share board lookup.src/commands/sprint.rs:createandupdatehandlers + 6 new wiremock tests covering full body, name-only body, bad date format, name-only update, "nothing supplied" error, and sprint-not-found error.src/yt/output.rs:parse_ymd_to_ms_utcmoved here fromsrc/commands/issue/history.rs(introduced in #47), since both surfaces share the sameYYYY-MM-DD UTC -> ms-since-epochconversion. Two unit tests followed.src/commands/issue/history.rs: switched to the sharedparse_ymd_to_ms_utc; dropped the now-duplicate helper and its tests.Test plan
src/commands/sprint.rsandsrc/yt/output.rs. Test inventory:create_posts_full_body_with_dates,create_posts_name_only_when_dates_omitted,create_rejects_bad_date_format,update_renames_only_when_only_name_supplied,update_rejects_when_nothing_supplied,update_errors_when_sprint_name_not_on_board,parse_ymd_accepts_iso_date,parse_ymd_rejects_garbage.just pre-commitpasses (fmt, clippy, build, test). 239 tests pass. The same pre-existing unrelatedcommands::update::tests::check_writable_returns_friendly_message_on_readonly_dirflake from #45 / #46 / #47 still fails and reproduces onorigin/main.yt sprint create --board "<scratch board>" --name "Sprint Z" --start 2024-01-02 --finish 2024-02-01, thenyt sprint update "Sprint Z" --board "<scratch board>" --name "Sprint Z (renamed)", thenyt sprint list --board "<scratch board>"to verify both the create and the partial update landed.Open question deferred to follow-up
YouTrack accepts the date fields with sentinel zeros and treats them as "unset"; clearing a date back to unset on an existing sprint via this CLI would need a
--start clearor similar flag. Not in scope for YT-2 and no concrete user need yet; easy to bolt on later.