Commit graph

49 commits

Author SHA1 Message Date
Babak K. Shandiz
ab9c99ec04
docs(cache delete): remove redundant comment
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-10-02 11:36:00 +01:00
Babak K. Shandiz
d574873f3b
docs(cache delete): add godoc for deleteCacheByKey
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-10-02 11:33:26 +01:00
Lucas
ccfc2c3045
fix(cache): report correct deleted count for key and key+ref deletions
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.
2025-10-01 18:44:24 +02:00
Babak K. Shandiz
08e4aa892e
test(cache delete): combine test cases for invalid/non-existent refs
Also note that the API never returns HTTP 422 for invalid refs.

Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-08-28 11:07:49 +01:00
Babak K. Shandiz
d1a404a060
test(cache delete): replace HTTP 204 with 200 to match API behaviour
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-08-28 11:06:58 +01:00
Babak K. Shandiz
02d50700b5
docs(cache delete): explain different API responses
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-08-28 11:05:28 +01:00
Babak K. Shandiz
d457a1bce0
test(cache delete): add test case for key arg and --all
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-08-28 10:12:19 +01:00
Babak K. Shandiz
2dd54ae921
refactor(cache delete): simplify error handling
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-08-28 10:08:04 +01:00
Babak K. Shandiz
842d3449b4
refactor(cache delete): simplify condition
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-08-28 10:02:03 +01:00
Lucas
926327ce6d
fix(cache): validate --ref flag usage with cache ID
* Ensure that the `--ref` flag cannot be used in conjunction with a cache ID.
* Update error handling to provide clear feedback when this condition is violated.
* Add tests to cover scenarios involving the `--ref` flag and cache ID.
2025-08-27 19:54:19 +02:00
Lucas
1a19918581
fix(cache): prevent using --ref flag with cache ID
* Added validation to ensure that the `--ref` flag cannot be used when a cache ID is provided.
* Updated error message to include the reference when a cache is not found with the specified `--ref`.
2025-08-27 19:38:01 +02:00
Lucas
5c292286cf
refactor(cache): extract cache ID parsing logic
* Replaced direct conversion of cache ID string to int with a dedicated `parseCacheID` function.
* Improved readability and maintainability of the `deleteCaches` function.
2025-08-27 19:37:39 +02:00
Lucas
047326fcb4
fix(cache): update error message for missing cache key with --ref flag
* Changed the error message from "--ref cannot be used without cache key/ID" to "must provide a cache key" for clarity.
* Updated corresponding test case to reflect the new error message.
2025-08-27 04:56:48 +02:00
Lucas
3ba82b58a9
chore(cache): improve help text for --ref flag in cache deletion
* Clarified the description of the `--ref` flag to specify its purpose more accurately.
* Ensures users understand that it narrows down deletion by cache key and ref.
2025-08-27 04:56:48 +02:00
Lucas
bfb1354e51
test(cache): add tests for --ref flag in cache deletion
* Implemented test cases for handling the `--ref` flag in cache deletion commands.
* Added validation for using `--ref` with cache key and ID.
* Ensured proper error messages are returned for invalid usage of `--ref`.
2025-08-27 04:56:48 +02:00
Lucas
aff2bfaa5c
feat(cache): add support for --ref flag in cache deletion
- Introduced `--ref` flag to narrow down cache deletion to a specific branch or PR reference.
- Updated command examples to include usage of `--ref`.
- Added validation to ensure `--ref` cannot be used with `--all` and must accompany a cache key/ID.
2025-08-27 04:56:46 +02:00
Andy Feller
d2cd14b4cd Remove out of scope changes, update list commands
After discussing this with the team, the `gh config` changes to display `accessible_colors` have been removed from this branch being outside of acceptance criteria.  This will be moved to a separate issue along with any other work needed to finalize the public preview such as `gh help` entries for `GH_ACCESSIBLE_COLORS` environment variable.

List commands that use ColorScheme.Gray have been updated to use ColorScheme.Muted.
2025-03-31 11:58:30 -04:00
Azeem Sajid
33c30d5bd1 Inconsistent format of examples in help text 2025-02-27 16:26:25 +05:00
Azeem Sajid
9389628323 Update tests 2025-02-19 10:31:20 +05:00
Azeem Sajid
db8e81009c Merge branch '9897-gh-cache-delete-exit-code' of github.com:iamazeem/cli into 9897-gh-cache-delete-exit-code 2025-02-19 10:22:53 +05:00
Azeem Sajid
76efb5ac81 Fix non-TTY case 2025-02-19 10:22:31 +05:00
Azeem Sajid
17e7b57b3b Use API without shorthand flag 2025-02-07 18:03:35 +05:00
Azeem Sajid
a29e74483a Update tests 2025-02-07 17:56:52 +05:00
Azeem Sajid
09ec38e8d7 Update tests 2025-02-06 22:50:26 +05:00
Tyler McGoffin
2f0f387e11
Add test cases for succeed on no cache and api errors for --all (#1) 2025-02-06 22:47:01 +05:00
Azeem Sajid
9e13890c77 Remove short (abbreviated) flag support 2025-02-06 11:56:08 +05:00
Azeem Sajid
d6be4981be Address PR review comments 2025-01-31 12:28:00 +05:00
Azeem Sajid
82ee9a2c75 [gh cache delete --all] Add --succeed-on-no-caches flag to return exit code 0 2025-01-29 14:53:09 +05:00
Kynan Ware
74f13a9b4f
Apply suggestions from code review
Co-authored-by: Andy Feller <andyfeller@github.com>
2024-11-21 13:55:35 -07:00
bagtoad
677ed2cdcf Refactor command documentation to use heredoc 2024-11-21 13:23:03 -07:00
William Martin
a569d1030d Export empty results for cache list 2024-11-06 13:02:14 +01:00
Viktor Szépe
6d9dd57774 Fix typos 2024-05-09 20:15:27 +00:00
William Martin
b7ea025475 Make minor cache list ref flag adjustments 2024-02-29 13:02:49 +01:00
toshimaru
818c158212
feat: Add ref option to gh cache list
List GitHub Actions caches with `ref` filtering.

> ref string
> The full Git reference for narrowing down the cache. The ref for a branch should be formatted as refs/heads/<branch name>. To reference a pull request use refs/pull/<number>/merge.

ref. https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#list-github-actions-caches-for-a-repository
2024-02-17 09:28:06 +09:00
William Martin
960c6662ca Update cache list key example to be clearer 2024-02-09 17:21:43 +01:00
William Martin
b7ffe6ed27 Add cache list key example to help 2024-02-09 17:19:31 +01:00
William Martin
662db3ca9e Test cache list key is sent to API 2024-02-09 17:15:15 +01:00
William Martin
8768eece8f Change cache list key to lowercase short 2024-02-09 17:14:59 +01:00
toshimaru
8252e59f17
feat: Add cache key option to gh cache list
Add `key` option to `gh cache list` command.

```
-K, --key string        Filter by cache key prefix
```

> An explicit key or prefix for identifying the cache

ref. https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#list-github-actions-caches-for-a-repository

- Add key option related tests to `TestNewCmdList`
2024-02-05 12:42:00 +09:00
w1mvy
9dd5805f9c
Add json export flags to variable list command (#8516) 2024-01-17 10:09:09 -08:00
William Martin
a9bdd8d186 Fix flaky tests coupled to relative dates 2023-12-13 14:44:16 +01:00
Heath Stewart
7738b6187c
Add headers to all tables (#8157) 2023-10-20 11:20:02 +02:00
Andy Feller
4dc80c3925
Merge pull request #7954 from siketyan/feat/cache-list-json
feat(cache): Add JSON exporting support for cache list
2023-09-26 07:51:16 -04:00
Natsuki Ikeguchi
9ef7a5f262
test: Add unit test for cache.ExportData 2023-09-24 02:53:08 +09:00
Benoit Pierre
564d07ce00 cache/delete: percent-encode keys 2023-09-21 16:32:53 +02:00
Natsuki Ikeguchi
1749574310
feat(cache): Add JSON exporting support for cache list
Signed-off-by: Natsuki Ikeguchi <me@s6n.jp>
2023-09-07 01:35:03 +09:00
cawfeecake
aa231319ca
Add missing "ls" aliases to list commands (#7818) 2023-08-10 09:08:15 -07:00
Josh Kraft
1dc54f85fb typo 2023-05-03 11:08:32 -06:00
Josh Kraft
213a59b8bd create cache commands 2023-05-03 11:03:50 -06:00