MCPcopy
hub / github.com/cli/cli / editRun

Function editRun

pkg/cmd/repo/edit/edit.go:235–358  ·  view source on GitHub ↗
(ctx context.Context, opts *EditOptions)

Source from the content-addressed store, hash-verified

233}
234
235func editRun(ctx context.Context, opts *EditOptions) error {
236 repo := opts.Repository
237
238 if opts.InteractiveMode {
239 detector := opts.Detector
240 if detector == nil {
241 cachedClient := api.NewCachedHTTPClient(opts.HTTPClient, time.Hour*24)
242 detector = fd.NewDetector(cachedClient, repo.RepoHost())
243 }
244 repoFeatures, err := detector.RepositoryFeatures()
245 if err != nil {
246 return err
247 }
248
249 apiClient := api.NewClientFromHTTP(opts.HTTPClient)
250 fieldsToRetrieve := []string{
251 "defaultBranchRef",
252 "deleteBranchOnMerge",
253 "description",
254 "hasIssuesEnabled",
255 "hasProjectsEnabled",
256 "hasWikiEnabled",
257 // TODO: GitHub Enterprise Server does not support has_discussions yet
258 // "hasDiscussionsEnabled",
259 "homepageUrl",
260 "isInOrganization",
261 "isTemplate",
262 "mergeCommitAllowed",
263 "rebaseMergeAllowed",
264 "repositoryTopics",
265 "stargazerCount",
266 "squashMergeAllowed",
267 "watchers",
268 }
269 // TODO repoFeaturesCleanup
270 if repoFeatures.VisibilityField {
271 fieldsToRetrieve = append(fieldsToRetrieve, "visibility")
272 }
273 // TODO repoFeaturesCleanup
274 if repoFeatures.AutoMerge {
275 fieldsToRetrieve = append(fieldsToRetrieve, "autoMergeAllowed")
276 }
277
278 opts.IO.StartProgressIndicator()
279 fetchedRepo, err := api.FetchRepository(apiClient, opts.Repository, fieldsToRetrieve)
280 opts.IO.StopProgressIndicator()
281 if err != nil {
282 return err
283 }
284 err = interactiveRepoEdit(opts, fetchedRepo)
285 if err != nil {
286 return err
287 }
288 }
289
290 if opts.Edits.SecurityAndAnalysis != nil {
291 apiClient := api.NewClientFromHTTP(opts.HTTPClient)
292 repo, err := api.FetchRepository(apiClient, opts.Repository, []string{"viewerCanAdminister"})

Callers 3

Test_editRunFunction · 0.70
Test_editRun_interactiveFunction · 0.70
NewCmdEditFunction · 0.70

Calls 15

NewCachedHTTPClientFunction · 0.92
NewClientFromHTTPFunction · 0.92
FetchRepositoryFunction · 0.92
CreateRepoTransformToV4Function · 0.92
NewStringSetFunction · 0.92
FullNameFunction · 0.92
interactiveRepoEditFunction · 0.85
getTopicsFunction · 0.85
setTopicsFunction · 0.85
AddValuesMethod · 0.80
RemoveValuesMethod · 0.80
EqualMethod · 0.80

Tested by 2

Test_editRunFunction · 0.56
Test_editRun_interactiveFunction · 0.56