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

Skip to content

Conversation

luxass
Copy link
Contributor

@luxass luxass commented Oct 1, 2025

Previously, deleting caches by key or key+ref could misreport the number of deleted entries, especially when multiple caches matched the criteria. This change ensures the actual number of deleted caches is reported by consuming the API response's total_count field.

resolves #11595

Previously, deleting caches by key or key+ref could misreport the number of deleted entries, especially when multiple caches matched the criteria. This change ensures the actual number of deleted caches is reported by consuming the API response's total_count field.
@luxass luxass temporarily deployed to cli-automation October 1, 2025 16:45 — with GitHub Actions Inactive
@luxass luxass marked this pull request as ready for review October 1, 2025 16:56
@luxass luxass requested a review from a team as a code owner October 1, 2025 16:56
@luxass luxass requested review from BagToad and Copilot October 1, 2025 16:56
@luxass luxass temporarily deployed to cli-automation October 1, 2025 16:56 — with GitHub Actions Inactive
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Oct 1, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Fixes incorrect cache deletion count reporting when deleting caches by key or key+ref, ensuring the actual number of deleted caches is displayed by consuming the API response's total_count field.

  • Replaced hardcoded deletion count with API response's total_count field
  • Split cache deletion logic into separate functions for ID and key-based deletions
  • Added comprehensive test coverage for multiple cache deletions scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/cmd/cache/delete/delete.go Refactored deletion logic to track actual deleted count and separated API calls by deletion type
pkg/cmd/cache/delete/delete_test.go Added test cases for multiple cache deletions and updated existing tests to use proper JSON responses

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@babakks babakks self-requested a review October 2, 2025 08:58
Copy link
Member

@babakks babakks left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks again for your contribution, @luxass! 🚀

I'll push a few more commits and will then merge.

@babakks babakks changed the title fix(cache): report correct deleted count for key and key+ref deletions fix(cache delete): report correct deleted count for key and key+ref deletions Oct 2, 2025
@babakks babakks enabled auto-merge October 2, 2025 10:38
@babakks babakks merged commit 32a9c4b into cli:trunk Oct 2, 2025
11 checks passed
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Oct 17, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cli/cli](https://github.com/cli/cli) | minor | `v2.81.0` -> `v2.82.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.82.0`](https://github.com/cli/cli/releases/tag/v2.82.0): GitHub CLI 2.82.0

[Compare Source](cli/cli@v2.81.0...v2.82.0)

##### ✨ Features

- `gh pr edit`: Only fetch org teams for reviewers when required by [@&#8203;BagToad](https://github.com/BagToad) in [#&#8203;11835](cli/cli#11835)

##### 🐛 Fixes

- fix(cache delete): report correct deleted count for key and key+ref deletions by [@&#8203;luxass](https://github.com/luxass) in [#&#8203;11838](cli/cli#11838)
- `gh agent-task create`: Fix `--follow` not killing the progress indicator by [@&#8203;BagToad](https://github.com/BagToad) in [#&#8203;11879](cli/cli#11879)
- `gh agent-task create`: Fix targetting upstream instead of default repo by [@&#8203;BagToad](https://github.com/BagToad) in [#&#8203;11896](cli/cli#11896)
- Fix `auth login` and `auth refresh` to use UNIX socket by [@&#8203;babakks](https://github.com/babakks) in [#&#8203;11922](cli/cli#11922)

**Full Changelog**: <cli/cli@v2.81.0...v2.82.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:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNDguNiIsInVwZGF0ZWRJblZlciI6IjQxLjE0OC42IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
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 cache delete <cache-key> misreports count when multiple match

3 participants