| 233 | } |
| 234 | |
| 235 | func 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"}) |