Skip to content

Conversation

@davidspek
Copy link
Contributor

@davidspek davidspek commented Nov 5, 2025

Fixes #12102

To cleanup caches from PR branches once they are merged, the current approach is to create a script that list all the caches for the PR ref, gets the IDs, and then iterate through each ID to delete the cache. This approach is also used in the official GitHub documentation. Having to do this scripting and choosing some number for the limit of caches to fetch, which might not include everything, seems needlessly complex.

This PR adds the capability to pass both --all and --ref, making cleaning up all the caches after a PR is merged as simple as gh cache delete --all --ref refs/pull/<PR-number>/merge.

Copilot AI review requested due to automatic review settings November 5, 2025 14:28
@davidspek davidspek requested a review from a team as a code owner November 5, 2025 14:28
@davidspek davidspek requested a review from BagToad November 5, 2025 14:28
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Nov 5, 2025
@cliAutomation
Copy link
Collaborator

Hi! Thanks for the pull request. Please ensure that this change is linked to an issue by mentioning an issue number in the description of the pull request. If this pull request would close the issue, please put the word 'Fixes' before the issue number somewhere in the pull request body. If this is a tiny change like fixing a typo, feel free to ignore this message.

Copy link
Contributor

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

This PR adds support for using the --ref flag in conjunction with --all when deleting caches, allowing users to delete all caches for a specific git reference (branch or PR).

  • Removed the mutual exclusivity check that prevented --ref and --all from being used together
  • Updated validation logic to allow --ref with --all but still require a cache key when --ref is used without --all
  • Modified deleteRun to pass the ref parameter to GetCaches when deleting all caches for a specific ref

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@davidspek davidspek force-pushed the feat/delete-all-cache-ref branch from 47d8f2f to e8c586f Compare November 5, 2025 14:37
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Thank you for your pull request! 🎉

This PR appears to fix the following issues that are not labeled with help wanted Contributions welcome :

As outlined in our Contributing Guidelines, we expect that PRs are only created for issues that have been labeled help wanted.

While we appreciate your initiative, please note that:

  • PRs for non-help wanted issues may not be reviewed immediately as they might not align with our current priorities
  • The issue might already be assigned to a team member or planned for a specific release
  • We may need to close this PR. For example, if it conflicts with ongoing work or architectural decisions

What happens next:

  • Our team will review this PR and the associated issues
  • We may add the help wanted label to the issues, if appropriate, and review this pull request
  • In some cases, we may need to close the PR. For example, if it doesn't fit our current roadmap

Thank you for your understanding and contribution to the project! 🙏

This comment was automatically generated by cliAutomation.

@davidspek davidspek force-pushed the feat/delete-all-cache-ref branch from e8c586f to fb28c59 Compare November 10, 2025 08:47
@babakks
Copy link
Member

babakks commented Nov 13, 2025

Closing as explained in #12102 (comment).

@babakks babakks closed this Nov 13, 2025
@BagToad BagToad reopened this Jan 19, 2026
@davidspek davidspek force-pushed the feat/delete-all-cache-ref branch 2 times, most recently from c474b26 to 28361b3 Compare January 19, 2026 17:22
Signed-off-by: David van der Spek <david.vanderspek@flyrlabs.com>
Signed-off-by: David van der Spek <david.vanderspek@flyrlabs.com>
@davidspek davidspek force-pushed the feat/delete-all-cache-ref branch from 28361b3 to 9cdc0c4 Compare January 20, 2026 07:30
Copy link
Member

@BagToad BagToad 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 to me @davidspek! Thank you for your patience, proposing this idea, and implementing it!

@BagToad BagToad merged commit 3e8855f into cli:trunk Jan 20, 2026
11 checks passed
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jan 22, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cli/cli](https://github.com/cli/cli) | minor | `v2.85.0` → `v2.86.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.86.0`](https://github.com/cli/cli/releases/tag/v2.86.0): GitHub CLI 2.86.0

[Compare Source](cli/cli@v2.85.0...v2.86.0)

#### :copilot:  Install and run GitHub Copilot CLI directly from `gh`

Since we deprecated the [GitHub Copilot in the CLI](https://github.blog/changelog/2025-09-25-upcoming-deprecation-of-gh-copilot-cli-extension/) extension in favor of the new agentic [GitHub Copilot CLI](https://github.com/github/copilot-cli), we want to give developers using `gh` a simple way to get started using our most powerful terminal assistant.

- `gh copilot` will prompt to install, then run Copilot CLI
- `gh copilot <args>` will execute the Copilot CLI, forwarding any arguments and flags

For more information and usage options, run `gh copilot --help`.

#### What's Changed

##### ✨ Features

- `gh copilot`: add native `copilot` command to execute/install copilot cli by [@&#8203;devm33](https://github.com/devm33) in [#&#8203;12444](cli/cli#12444)
- `gh cache delete`: allow for delete all caches for a ref by [@&#8203;davidspek](https://github.com/davidspek) in [#&#8203;12101](cli/cli#12101)
- `gh pr create`: error when head and base refs are identical in pr create by [@&#8203;majiayu000](https://github.com/majiayu000) in [#&#8203;12376](cli/cli#12376)

##### 📚 Docs & Chores

- Fix Windows asset URL in `copilot` command tests by [@&#8203;babakks](https://github.com/babakks) in [#&#8203;12500](cli/cli#12500)
- Update contributing guidelines for clarity by [@&#8203;BagToad](https://github.com/BagToad) in [#&#8203;12505](cli/cli#12505)

#### New Contributors

- [@&#8203;devm33](https://github.com/devm33) made their first contribution in [#&#8203;12444](cli/cli#12444)
- [@&#8203;davidspek](https://github.com/davidspek) made their first contribution in [#&#8203;12101](cli/cli#12101)

**Full Changelog**: <cli/cli@v2.85.0...v2.86.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:eyJjcmVhdGVkSW5WZXIiOiI0Mi44Ni4xIiwidXBkYXRlZEluVmVyIjoiNDIuODYuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
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.

cache: allow for easy cleanup of branch or PR caches

4 participants