Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@iamazeem
Copy link
Contributor

@iamazeem iamazeem commented Feb 5, 2025

Fixes #10342.

# number (float32)
$ gh project item-edit --project-id $projectId --id $itemId --field-id $fieldId --number 69.84
GraphQL: Number values cannot exceed 8 decimal places (updateProjectV2ItemFieldValue)

# number (float64)
$ bin/gh project item-edit --project-id $projectId --id $itemId --field-id $fieldId --number 69.84
Edited item "Test"

@iamazeem iamazeem requested a review from a team as a code owner February 5, 2025 11:34
@iamazeem iamazeem requested a review from BagToad February 5, 2025 11:34
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Feb 5, 2025
@andyfeller
Copy link
Member

@iamazeem : I'm catching up on #10342 to wrap up triaging how big of a problem we have beyond gh project item-edit such as other gh project commands we might have problems with.

Generally, we prefer maintainers capturing acceptance criteria and marking issues as help wanted as a way of signaling they are available for contributions or core being work that maintainers want to do themselves.

While I wrap this up, what are you thoughts on how the associated tests should be updated to ensure this continues to work as expected?

func TestNewCmdeditItem(t *testing.T) {
tests := []struct {
name string
cli string
wants editItemOpts
wantsErr bool
wantsErrMsg string
wantsExporter bool
}{
{
name: "missing-id",
cli: "",
wantsErr: true,
wantsErrMsg: "required flag(s) \"id\" not set",
},
{
name: "invalid-flags",
cli: "--id 123 --text t --date 2023-01-01",
wantsErr: true,
wantsErrMsg: "only one of `--text`, `--number`, `--date`, `--single-select-option-id` or `--iteration-id` may be used",
},
{
name: "item-id",
cli: "--id 123",
wants: editItemOpts{
itemID: "123",
},
},
{
name: "number",
cli: "--number 456 --id 123",
wants: editItemOpts{
number: 456,
itemID: "123",
},
},
{
name: "field-id",
cli: "--field-id FIELD_ID --id 123",
wants: editItemOpts{
fieldID: "FIELD_ID",
itemID: "123",
},
},
{
name: "project-id",
cli: "--project-id PROJECT_ID --id 123",
wants: editItemOpts{
projectID: "PROJECT_ID",
itemID: "123",
},
},
{
name: "text",
cli: "--text t --id 123",
wants: editItemOpts{
text: "t",
itemID: "123",
},
},
{
name: "date",
cli: "--date 2023-01-01 --id 123",
wants: editItemOpts{
date: "2023-01-01",
itemID: "123",
},
},
{
name: "single-select-option-id",
cli: "--single-select-option-id OPTION_ID --id 123",
wants: editItemOpts{
singleSelectOptionID: "OPTION_ID",
itemID: "123",
},
},
{
name: "iteration-id",
cli: "--iteration-id ITERATION_ID --id 123",
wants: editItemOpts{
iterationID: "ITERATION_ID",
itemID: "123",
},
},
{
name: "clear",
cli: "--id 123 --field-id FIELD_ID --project-id PROJECT_ID --clear",
wants: editItemOpts{
itemID: "123",
fieldID: "FIELD_ID",
projectID: "PROJECT_ID",
clear: true,
},
},
{
name: "json",
cli: "--format json --id 123",
wants: editItemOpts{
itemID: "123",
},
wantsExporter: true,
},
}
t.Setenv("GH_TOKEN", "auth-token")
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ios, _, _, _ := iostreams.Test()
f := &cmdutil.Factory{
IOStreams: ios,
}
argv, err := shlex.Split(tt.cli)
assert.NoError(t, err)
var gotOpts editItemOpts
cmd := NewCmdEditItem(f, func(config editItemConfig) error {
gotOpts = config.opts
return nil
})
cmd.SetArgs(argv)
_, err = cmd.ExecuteC()
if tt.wantsErr {
assert.Error(t, err)
assert.Equal(t, tt.wantsErrMsg, err.Error())
return
}
assert.NoError(t, err)
assert.Equal(t, tt.wants.number, gotOpts.number)
assert.Equal(t, tt.wants.itemID, gotOpts.itemID)
assert.Equal(t, tt.wantsExporter, gotOpts.exporter != nil)
assert.Equal(t, tt.wants.title, gotOpts.title)
assert.Equal(t, tt.wants.fieldID, gotOpts.fieldID)
assert.Equal(t, tt.wants.projectID, gotOpts.projectID)
assert.Equal(t, tt.wants.text, gotOpts.text)
assert.Equal(t, tt.wants.number, gotOpts.number)
assert.Equal(t, tt.wants.date, gotOpts.date)
assert.Equal(t, tt.wants.singleSelectOptionID, gotOpts.singleSelectOptionID)
assert.Equal(t, tt.wants.iterationID, gotOpts.iterationID)
assert.Equal(t, tt.wants.clear, gotOpts.clear)
})
}
}

@iamazeem
Copy link
Contributor Author

iamazeem commented Feb 5, 2025

@andyfeller

I'm catching up on #10342 to wrap up triaging how big of a problem we have beyond gh project item-edit such as other gh project commands we might have problems with.

Generally, we prefer maintainers capturing acceptance criteria and marking issues as help wanted as a way of signaling they are available for contributions or core being work that maintainers want to do themselves.

Please take your time.
I was able to verify and test it locally.
Wanted to verify it through CI as well.

what are you thoughts on how the associated tests should be updated to ensure this continues to work as expected?

Looked into it and pushed 277f274 where:

  • added a new test with floating number for the CLI args, and
  • updated GQL API number test for the floating point number.

Looks like the GQL API test may further be enhanced with the complete response. πŸ€”
But, the other tests for the field values are not checking for that so I'm not so sure about that.
Please share how you think to test it against these cases. Thanks!

Copy link
Member

@andyfeller andyfeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Working with @BagToad, we've removed the AC for client-side validation of --number max values in favor for server-side validation improvements with the Projects team.

@andyfeller andyfeller merged commit 9da292d into cli:trunk Feb 6, 2025
9 checks passed
@iamazeem iamazeem deleted the 10342-gh-project-item-edit-number branch February 7, 2025 04:43
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Feb 13, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cli/cli](https://github.com/cli/cli) | minor | `v2.66.1` -> `v2.67.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>cli/cli (cli/cli)</summary>

### [`v2.67.0`](https://github.com/cli/cli/releases/tag/v2.67.0): GitHub CLI 2.67.0

[Compare Source](cli/cli@v2.66.1...v2.67.0)

#### `gh pr checkout` now supports interactively selecting a pull request

Similar to commands like `gh workflow run` which prompts for a workflow to run, now `gh pr checkout` will prompt for a pull request to checkout. The list is currently limited to the most recent 10 pull requests in the repository.

https://github.com/user-attachments/assets/0b2e3761-7318-4573-8a23-ae6f1a44b018

Big thank you to [@&#8203;nilvng](https://github.com/nilvng) for implementing this πŸ™Œ

#### Contributing guidelines updated

We've updated our [`CONTRIBUTING.md`](https://github.com/cli/cli/blob/trunk/.github/CONTRIBUTING.md) guidelines to give more clarity around old `help wanted` issues.

*TLDR*:

-   Please directly mention `@cli/code-reviewers` when an issue you want to work on does not have clear Acceptance Criteria
-   Please only open pull requests for issues with *both*  the help wanted label and clear Acceptance Criteria
-   Please avoid expanding pull request scope to include changes that are not described in the connected issue's Acceptance Criteria

Note: Acceptance Criteria is posted as an issue comment by a core maintainer.

See cli/cli#10381 and cli/cli#10395 for more information.

❓ Have feedback on anything? We'd love to hear from you in a discussion post ❀️

#### What's Changed

##### ✨ Features

-   feat: let user select pr to checkout by [@&#8203;nilvng](https://github.com/nilvng) in cli/cli#9868
-   feat: Add support for deleting autolink references by [@&#8203;hoffm](https://github.com/hoffm) in cli/cli#10362
-   \[gh extensions install] Improve help text and error message by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10333
-   Error when `gh repo rename` is used with a new repo name that contains an owner by [@&#8203;timrogers](https://github.com/timrogers) in cli/cli#10364
-   Attestation bundle fetch improvements by [@&#8203;malancas](https://github.com/malancas) in cli/cli#10233
-   \[gh project item-list] Add `iterationId` field in ProjectV2ItemFieldIterationValue by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10329

##### πŸ› Fixes

-   \[gh api] Fix mutual exclusion messages of `--slurp` flag by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10332
-   Exit with error if no matching predicate type exists by [@&#8203;kommendorkapten](https://github.com/kommendorkapten) in cli/cli#10421
-   Do not try to parse bodies for HEAD requests by [@&#8203;jsoref](https://github.com/jsoref) in cli/cli#10388
-   \[gh project item-edit] Fix number type by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10374
-   \[gh workflow run] Improve error handling for `--ref` flag by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10328
-   \[gh config] Escape pipe symbol in Long desc for website manual by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10371

##### πŸ“š Docs & Chores

-   Fix logic error in contributing docs by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10395
-   Docs: Clarify guidelines for `help wanted` issues and pull requests by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10381
-   \[gh pr status] Mention `gh pr checks` in the `Long` section by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10389
-   \[docs/releasing.md] Add basic info for homebrew update flow by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10344
-   \[gh issue/pr list] Improve help text by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10335
-   Remove v1 project 'add to board' automation from prauto workflow by [@&#8203;hoffm](https://github.com/hoffm) in cli/cli#10331
-   Note: the following pair of MRs was reverted and never made into a release
    -   \[gh repo edit] Allow setting commit message defaults by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10363
    -   Revert "\[gh repo edit] Allow setting commit message defaults" by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10372

##### :dependabot: Dependencies

-   Bump google.golang.org/protobuf from 1.36.4 to 1.36.5 by [@&#8203;dependabot](https://github.com/dependabot) in cli/cli#10379

**Full Changelog**: cli/cli@v2.66.1...v2.67.0

</details>

---

### Configuration

πŸ“… **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

β™» **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

πŸ”• **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNjUuMSIsInVwZGF0ZWRJblZlciI6IjM5LjE2NS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gh project item-edit command fails with value for --number is floating point

3 participants