MCPcopy Create free account
hub / github.com/cli/cli / editRun

Function editRun

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

Source from the content-addressed store, hash-verified

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

Tested by 2

Test_editRunFunction · 0.56
Test_editRun_interactiveFunction · 0.56