| 198 | } |
| 199 | |
| 200 | func createRun(opts *CreateOptions) (err error) { |
| 201 | httpClient, err := opts.HttpClient() |
| 202 | if err != nil { |
| 203 | return |
| 204 | } |
| 205 | apiClient := api.NewClientFromHTTP(httpClient) |
| 206 | |
| 207 | baseRepo, err := opts.BaseRepo() |
| 208 | if err != nil { |
| 209 | return |
| 210 | } |
| 211 | |
| 212 | // TODO projectsV1Deprecation |
| 213 | // Remove this section as we should no longer need to detect |
| 214 | if opts.Detector == nil { |
| 215 | cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24) |
| 216 | opts.Detector = fd.NewDetector(cachedClient, baseRepo.RepoHost()) |
| 217 | } |
| 218 | |
| 219 | projectsV1Support := opts.Detector.ProjectsV1() |
| 220 | issueFeatures, err := opts.Detector.IssueFeatures() |
| 221 | if err != nil { |
| 222 | return err |
| 223 | } |
| 224 | |
| 225 | isTerminal := opts.IO.IsStdoutTTY() |
| 226 | |
| 227 | var milestones []string |
| 228 | if opts.Milestone != "" { |
| 229 | milestones = []string{opts.Milestone} |
| 230 | } |
| 231 | |
| 232 | // Replace special values in assignees |
| 233 | // For web mode, @copilot should be replaced by name; otherwise, login. |
| 234 | assigneeReplacer := prShared.NewSpecialAssigneeReplacer(apiClient, baseRepo.RepoHost(), issueFeatures.ApiActorsSupported, !opts.WebMode) |
| 235 | assignees, err := assigneeReplacer.ReplaceSlice(opts.Assignees) |
| 236 | if err != nil { |
| 237 | return err |
| 238 | } |
| 239 | assigneeSet := set.NewStringSet() |
| 240 | assigneeSet.AddValues(assignees) |
| 241 | |
| 242 | tb := prShared.IssueMetadataState{ |
| 243 | Type: prShared.IssueMetadata, |
| 244 | ApiActorsSupported: issueFeatures.ApiActorsSupported, // TODO ApiActorsSupported |
| 245 | Assignees: assigneeSet.ToSlice(), |
| 246 | Labels: opts.Labels, |
| 247 | ProjectTitles: opts.Projects, |
| 248 | Milestones: milestones, |
| 249 | Title: opts.Title, |
| 250 | Body: opts.Body, |
| 251 | } |
| 252 | |
| 253 | if opts.RecoverFile != "" { |
| 254 | err = prShared.FillFromJSON(opts.IO, opts.RecoverFile, &tb) |
| 255 | if err != nil { |
| 256 | err = fmt.Errorf("failed to recover input: %w", err) |
| 257 | return |