MCPcopy
hub / github.com/cli/cli / deleteRun

Function deleteRun

pkg/cmd/cache/delete/delete.go:119–157  ·  view source on GitHub ↗
(opts *DeleteOptions)

Source from the content-addressed store, hash-verified

117}
118
119func deleteRun(opts *DeleteOptions) error {
120 httpClient, err := opts.HttpClient()
121 if err != nil {
122 return fmt.Errorf("failed to create http client: %w", err)
123 }
124 client := api.NewClientFromHTTP(httpClient)
125
126 repo, err := opts.BaseRepo()
127 if err != nil {
128 return fmt.Errorf("failed to determine base repo: %w", err)
129 }
130
131 var toDelete []string
132 if opts.DeleteAll {
133 opts.IO.StartProgressIndicator()
134 caches, err := shared.GetCaches(client, repo, shared.GetCachesOptions{Limit: -1, Ref: opts.Ref})
135 opts.IO.StopProgressIndicator()
136 if err != nil {
137 return err
138 }
139 if len(caches.ActionsCaches) == 0 {
140 if opts.SucceedOnNoCaches {
141 if opts.IO.IsStdoutTTY() {
142 fmt.Fprintf(opts.IO.Out, "%s No caches to delete\n", opts.IO.ColorScheme().SuccessIcon())
143 }
144 return nil
145 } else {
146 return fmt.Errorf("%s No caches to delete", opts.IO.ColorScheme().FailureIcon())
147 }
148 }
149 for _, cache := range caches.ActionsCaches {
150 toDelete = append(toDelete, strconv.Itoa(cache.Id))
151 }
152 } else {
153 toDelete = append(toDelete, opts.Identifier)
154 }
155
156 return deleteCaches(opts, client, repo, toDelete)
157}
158
159func deleteCaches(opts *DeleteOptions, client *api.Client, repo ghrepo.Interface, toDelete []string) error {
160 cs := opts.IO.ColorScheme()

Callers 2

NewCmdDeleteFunction · 0.70
TestDeleteRunFunction · 0.70

Calls 11

NewClientFromHTTPFunction · 0.92
GetCachesFunction · 0.92
deleteCachesFunction · 0.85
IsStdoutTTYMethod · 0.80
SuccessIconMethod · 0.80
ColorSchemeMethod · 0.80
FailureIconMethod · 0.80
ErrorfMethod · 0.65
BaseRepoMethod · 0.65
StopProgressIndicatorMethod · 0.65

Tested by 1

TestDeleteRunFunction · 0.56