Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: regression introduced by new OriginalEstimate attribute #767

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: regression introduced by new OriginalEstimate attribute
The recent changes in PR #748 caused issues with jira-cli when used with Jira Enterprise On-Prem (now referred to as DataCenter). All requests started failing with the following error message:

```
Error:
  - timetracking: Field 'timetracking' cannot be set. It is not on the appropriate screen, or unknown.
```

The issue arises because, even if the `--original-estimate` option is not specified, the timetracking field is included in the JSON query.
This PR addresses the issue by ensuring that the timetracking field is only included in the JSON query if the `--original-estimate` option is set.
I have tested the fix, and all tests are passing.

Please review the changes and let me know if there are any concerns.
fabio42 committed Aug 26, 2024
commit b86ab73b65029deb94f64f2ac0993a66b4e87701
11 changes: 7 additions & 4 deletions pkg/jira/create.go
Original file line number Diff line number Diff line change
@@ -133,9 +133,6 @@ func (*Client) getRequestData(req *CreateRequest) *createRequest {
Summary: req.Summary,
Labels: req.Labels,
epicField: req.EpicField,
TimeTracking: struct {
OriginalEstimate string `json:"originalEstimate,omitempty"`
}{OriginalEstimate: req.OriginalEstimate},
}

switch v := req.Body.(type) {
@@ -219,6 +216,12 @@ func (*Client) getRequestData(req *CreateRequest) *createRequest {
}
data.Fields.M.AffectsVersions = versions
}
if req.OriginalEstimate != "" {
data.Fields.M.TimeTracking = &struct {
OriginalEstimate string `json:"originalEstimate,omitempty"`
}{OriginalEstimate: req.OriginalEstimate}
}

constructCustomFields(req.CustomFields, req.configuredCustomFields, &data)

return &data
@@ -307,7 +310,7 @@ type createFields struct {
AffectsVersions []struct {
Name string `json:"name,omitempty"`
} `json:"versions,omitempty"`
TimeTracking struct {
TimeTracking *struct {
OriginalEstimate string `json:"originalEstimate,omitempty"`
} `json:"timetracking,omitempty"`
epicField string