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