-
Couldn't load subscription status.
- Fork 7.3k
[gh workflow run] Improve error handling for --ref flag
#10328
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
[gh workflow run] Improve error handling for --ref flag
#10328
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the submission, @iamazeem! I've got a couple of questions I've sprinkled in PR comments, but there's one change I'd like to see: I ran the tests locally and we have a test failure. That should be fixed, and we should include tests to cover the new use-cases in TestRun. I didn't look too closely, and there's a chance that fixing the broken test also covers this use-case, but there may be more.
Let me know if you have any questions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man, it's frustrating to me that there's no tests for this file π€¦
I won't block this PR for lack of a test once the error message matches the AC, but if you want to take a stab at covering this with a test I won't stop you π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 [@​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 [@​nilvng](https://github.com/nilvng) in cli/cli#9868 - feat: Add support for deleting autolink references by [@​hoffm](https://github.com/hoffm) in cli/cli#10362 - \[gh extensions install] Improve help text and error message by [@​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 [@​timrogers](https://github.com/timrogers) in cli/cli#10364 - Attestation bundle fetch improvements by [@​malancas](https://github.com/malancas) in cli/cli#10233 - \[gh project item-list] Add `iterationId` field in ProjectV2ItemFieldIterationValue by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10329 ##### π Fixes - \[gh api] Fix mutual exclusion messages of `--slurp` flag by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10332 - Exit with error if no matching predicate type exists by [@​kommendorkapten](https://github.com/kommendorkapten) in cli/cli#10421 - Do not try to parse bodies for HEAD requests by [@​jsoref](https://github.com/jsoref) in cli/cli#10388 - \[gh project item-edit] Fix number type by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10374 - \[gh workflow run] Improve error handling for `--ref` flag by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10328 - \[gh config] Escape pipe symbol in Long desc for website manual by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10371 ##### π Docs & Chores - Fix logic error in contributing docs by [@​BagToad](https://github.com/BagToad) in cli/cli#10395 - Docs: Clarify guidelines for `help wanted` issues and pull requests by [@​BagToad](https://github.com/BagToad) in cli/cli#10381 - \[gh pr status] Mention `gh pr checks` in the `Long` section by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10389 - \[docs/releasing.md] Add basic info for homebrew update flow by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10344 - \[gh issue/pr list] Improve help text by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10335 - Remove v1 project 'add to board' automation from prauto workflow by [@​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 [@​iamazeem](https://github.com/iamazeem) in cli/cli#10363 - Revert "\[gh repo edit] Allow setting commit message defaults" by [@​BagToad](https://github.com/BagToad) in cli/cli#10372 #####Dependencies - Bump google.golang.org/protobuf from 1.36.4 to 1.36.5 by [@​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=-->
FindWorkflow had a code path that could error without handling that error that was introduced in #10328. I previously called out the lack of tests in this part of the code in my review, and punting them then bit us here: #10328 (review). As such, this fixes the panic, but also adds tests to cover the relevant code paths through FindWorkflow, including some tests for getWorkflowByID, getWorkflowsByName, and GetWorkflows. This does NOT seek to refactor the existing code, just cover the existing behavior and validate that we are resolving this panic (covered by TestFindWorkflow_nonHTTPError).
FindWorkflow had a code path that could error without handling that error that was introduced in cli#10328. I previously called out the lack of tests in this part of the code in my review, and punting them then bit us here: cli#10328 (review). As such, this fixes the panic, but also adds tests to cover the relevant code paths through FindWorkflow, including some tests for getWorkflowByID, getWorkflowsByName, and GetWorkflows. This does NOT seek to refactor the existing code, just cover the existing behavior and validate that we are resolving this panic (covered by TestFindWorkflow_nonHTTPError).
Fixes #9781.
Validate non-empty--refflag against the repo default branch