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

Function editRun

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

Callers 3

Test_editRunFunction · 0.70
Test_editRun_interactiveFunction · 0.70
NewCmdEditFunction · 0.70

Calls 15

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
EqualMethod · 0.80

Tested by 2

Test_editRunFunction · 0.56
Test_editRun_interactiveFunction · 0.56