feat: Add "sprint create" subcommand#894
feat: Add "sprint create" subcommand#894CyrilRoelandteNovance wants to merge 1 commit intoankitpokhrel:mainfrom
Conversation
99c98ac to
889481d
Compare
Cherry-picked from CyrilRoelandteNovance/sprint-create Original author: CyrilRoelandteNovance
889481d to
4058dd6
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds functionality to create sprints in JIRA via a new jira sprint create subcommand. Users can specify sprint details like name, start/end dates, and goals through command-line flags or interactive prompts.
Changes:
- Adds API client methods for creating sprints with request/response types
- Implements
sprint createCLI subcommand with flag parsing and interactive prompts - Adds test coverage for the new sprint creation API endpoint
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/jira/sprint.go | Adds CreateSprint method with request/response types for sprint creation API |
| pkg/jira/sprint_test.go | Adds test case for the CreateSprint functionality |
| pkg/jira/testdata/sprint-create.json | Provides test data for sprint creation response |
| internal/cmd/sprint/sprint.go | Registers the new create subcommand |
| internal/cmd/sprint/create/create.go | Implements the sprint creation command with CLI flags and interactive prompts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pkg/jira/sprint_test.go
Outdated
| assert.Error(t, &ErrUnexpectedResponse{}, err) | ||
| } | ||
|
|
||
| func TestCreateSrpint(t *testing.T) { |
There was a problem hiding this comment.
Corrected spelling of 'Srpint' to 'Sprint' in function name.
| func TestCreateSrpint(t *testing.T) { | |
| func TestCreateSprint(t *testing.T) { |
|
|
||
| func TestCreateSrpint(t *testing.T) { | ||
| server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| assert.NotNilf(t, r.Method, "invalid request method") |
There was a problem hiding this comment.
The assertion logic is incorrect. r.Method is a string and will never be nil. This assertion serves no purpose and should be removed.
There was a problem hiding this comment.
This might be true, but then this should also be modified (in a different commit) in TestEndSprint.
| StartDate: "2025-09-01T13:37:00.000+00:00", | ||
| EndDate: "2025-09-08T13:37:00.000+00:00", | ||
| Goal: "Testing jira-cli", | ||
| OriginBoardID: 42, |
There was a problem hiding this comment.
Test data inconsistency: OriginBoardID is set to 42 in the request but the expected response has OriginBoardID: 5 (line 452). This mismatch will cause the test to fail.
| OriginBoardID: 42, | |
| OriginBoardID: 5, |
There was a problem hiding this comment.
The tests were not failing but were indeed confusing, I fixed this by setting OriginBoardID to 42 and the sprint ID to 1337.
pkg/jira/sprint.go
Outdated
| defer func() { _ = res.Body.Close() }() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if res == nil { | ||
| return nil, ErrEmptyResponse | ||
| } |
There was a problem hiding this comment.
The defer statement is placed before the nil check for res (line 302). If res is nil, this will cause a panic. Move the defer statement after verifying that res is not nil.
| defer func() { _ = res.Body.Close() }() | |
| if err != nil { | |
| return nil, err | |
| } | |
| if res == nil { | |
| return nil, ErrEmptyResponse | |
| } | |
| if err != nil { | |
| return nil, err | |
| } | |
| if res == nil { | |
| return nil, ErrEmptyResponse | |
| } | |
| defer func() { _ = res.Body.Close() }() |
internal/cmd/sprint/create/create.go
Outdated
| if params.StartDate == "" { | ||
| qs = append(qs, &survey.Question{ | ||
| Name: "StartDate", | ||
| Prompt: &survey.Input{Message: "Start date (YYYY-MM-DDD)"}, |
There was a problem hiding this comment.
Corrected spelling of 'YYYY-MM-DDD' to 'YYYY-MM-DD' in date format message.
internal/cmd/sprint/create/create.go
Outdated
| if params.EndDate == "" { | ||
| qs = append(qs, &survey.Question{ | ||
| Name: "EndDate", | ||
| Prompt: &survey.Input{Message: "End date (YYYY-MM-DDD)"}, |
There was a problem hiding this comment.
Corrected spelling of 'YYYY-MM-DDD' to 'YYYY-MM-DD' in date format message.
4058dd6 to
c8106ff
Compare
|
Most comments from Copilot have been addressed, except the one regarding NotNilf, since I'm not sure Copilot is right about that. I'm not an experienced Go developer, so I have no idea about this myself and have just trusted the code in TestEndSprint :) |
c8106ff to
932e383
Compare
This commit adds a "jira sprint create" subcommand.