-
Couldn't load subscription status.
- Fork 7.3k
[gh cache delete --all] Add --succeed-on-no-caches flag to return exit code 0
#10327
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
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 contribution, @iamazeem! I've left a few comments throughout the code that I think we'll need to address before we ship this.
Additionally, I'd like to see some tests added to TestDeleteRun to cover these new code paths.
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.
Almost there 👍
I still think we're missing unit tests for TestDeleteRun. The tests you've added for NewCmdDelete don't actually test the internals of the command, as they are intercepted by the runF function.
I've gone ahead and opened a PR against your branch to demonstrate what I'm looking for. Notably, one of the tests I wrote is failing, which I think actually caught a case I hadn't considered before trying to write the tests 🥳 (Note: I did not fix the failure, yet, and figured that should be addressed here once that PR merges).
Let me know if you have any questions! And thanks again for all the work you've been putting into the cli lately 🙌
|
@jtmcg: Updated. Ready for review. Thanks! |
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.
Current Behaviour
➜ test-repo git:(feature) gh cache delete --all
X No caches to delete
➜ test-repo git:(feature) echo $?
1
Acceptance Criteria
Given I have no caches
When I run gh cache delete --all --succeed-on-no-caches
Then it exits 0
➜ test-repo git:(feature) ~/workspace/cli/bin/gh cache delete --all --succeed-on-no-caches
✓ No caches to delete
➜ test-repo git:(feature) echo $?
0
When I run gh cache delete <cache-id> --succeed-on-no-caches
Then I get an error that --succeed-on-no-caches can only be used in conjunction with --all
➜ test-repo git:(feature) ~/workspace/cli/bin/gh cache delete --succeed-on-no-caches
--succeed-on-no-caches must be used in conjunction with --all
Usage: gh cache delete [<cache-id> | <cache-key> | --all] [flags]
Flags:
-a, --all Delete all caches
--succeed-on-no-caches --all Return exit code 0 if no caches found. Must be used in conjunction with --all
LGTM thanks!
|
@jtmcg please re-review your requested changes. |
Damn, I had reviewed and had forgotten to push "submit review", so I had 2 comments in |
…cli into 9897-gh-cache-delete-exit-code
|
@jtmcg: Updated PR for the non-TTY case also. Please review. Thanks! Tests$ go clean -testcache && go test ./pkg/cmd/cache/delete/...
ok github.com/cli/cli/v2/pkg/cmd/cache/delete 0.005s
# TTY
$ bin/gh cache delete --repo iamazeem/test --succeed-on-no-caches --all
✓ No caches to delete
$ echo $?
0
# non-TTY
$ bin/gh cache delete --repo iamazeem/test --succeed-on-no-caches --all | cat |
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.67.0` -> `v2.68.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.68.0`](https://github.com/cli/cli/releases/tag/v2.68.0): GitHub CLI 2.68.0 [Compare Source](cli/cli@v2.67.0...v2.68.0) #### What's Changed ##### ✨ Features - \[gh repo view] Improve error message for forked repo by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10334 - Add signer-digest, source-ref, and source-digest options for `gh attestation verify` by [@​malancas](https://github.com/malancas) in cli/cli#10308 - \[gh pr checkout] Add --no-tags option to git fetch commands in checkout by [@​latzskim](https://github.com/latzskim) in cli/cli#10479 - \[`gh issue/pr comment`] Add `--create-if-none` and prompts to create a comment if no comment already exists by [@​latzskim](https://github.com/latzskim) in cli/cli#10427 - \[gh cache delete --all] Add `--succeed-on-no-caches` flag to return exit code 0 by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10327 - \[gh release create] Fail when there are no new commits since the last release by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10398 - update default upstream when forking repo during MR creation by [@​daviddl9](https://github.com/daviddl9) in cli/cli#10458 ##### 🐛 Fixes - Refactor `GetLocalAttestations` and clean up custom registry transport by [@​malancas](https://github.com/malancas) in cli/cli#10382 - Check `GH_REPO` too in addition to `--repo` for disambiguation by [@​williammartin](https://github.com/williammartin) in cli/cli#10539 - (Fixes `gh secret` subcommands not working outside of a repository) - Fix unhandled panic in FindWorkflow and add tests by [@​jtmcg](https://github.com/jtmcg) in cli/cli#10521 - Fix checkout when URL arg is from fork and cwd is upstream by [@​williammartin](https://github.com/williammartin) in cli/cli#10512 - \[gh api] Escape package name (URL encoding) for packages endpoint by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10384 - Fix `remoteResolver` caching issue by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10456 - Fix gh project item-edit to allow --number 0 as a valid value by [@​aryanbhosale](https://github.com/aryanbhosale) in cli/cli#10417 - Add mutex to fix race in attestation test client by [@​codysoyland](https://github.com/codysoyland) in cli/cli#10439 - Base64 decode GPG passphrase in deployment workflow by [@​BagToad](https://github.com/BagToad) in cli/cli#10546 ##### 📚 Docs & Chores - Deep Dive Document Release Process by [@​williammartin](https://github.com/williammartin) in cli/cli#10503 - Inconsistent format of examples in help text by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10508 - Inconsistent format of description of flags (starting with lowercase letter) by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10507 - Update Go version to 1.23 in CONTRIBUTING.md by [@​williammartin](https://github.com/williammartin) in cli/cli#10504 - Fix minor auth login help typo by [@​williammartin](https://github.com/williammartin) in cli/cli#10501 - docs: document how to revoke `gh` OAuth tokens in `auth logout`'s help by [@​BagToad](https://github.com/BagToad) in cli/cli#10490 - chore: update codespaces Go version by [@​BagToad](https://github.com/BagToad) in cli/cli#10491 - Allow injection of TUFMetadataDir in tests by [@​williammartin](https://github.com/williammartin) in cli/cli#10478 - refactor: use a more straightforward return value by [@​beforetech](https://github.com/beforetech) in cli/cli#10489 - Use subtests in attestation verification integration tests by [@​williammartin](https://github.com/williammartin) in cli/cli#10463 - Fix typo in README by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10445 - Update usage to lower-kebab-case by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10447 - Standardize URLs by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10429 - Remove trailing whitespace by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10430 #####Dependencies - Bump actions/attest-build-provenance from 2.2.0 to 2.2.2 by [@​dependabot](https://github.com/dependabot) in cli/cli#10518 - Bump github.com/go-jose/go-jose/v4 from 4.0.2 to 4.0.5 by [@​dependabot](https://github.com/dependabot) in cli/cli#10499 - Bump github.com/spf13/pflag from 1.0.5 to 1.0.6 by [@​dependabot](https://github.com/dependabot) in cli/cli#10338 </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:eyJjcmVhdGVkSW5WZXIiOiIzOS4xODYuMCIsInVwZGF0ZWRJblZlciI6IjM5LjE4Ni4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Fixes #9897