| 161 | } |
| 162 | |
| 163 | func createRun(opts *CreateOptions) (err error) { |
| 164 | httpClient, err := opts.HttpClient() |
| 165 | if err != nil { |
| 166 | return |
| 167 | } |
| 168 | apiClient := api.NewClientFromHTTP(httpClient) |
| 169 | |
| 170 | baseRepo, err := opts.BaseRepo() |
| 171 | if err != nil { |
| 172 | return |
| 173 | } |
| 174 | |
| 175 | // TODO projectsV1Deprecation |
| 176 | // Remove this section as we should no longer need to detect |
| 177 | if opts.Detector == nil { |
| 178 | cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24) |
| 179 | opts.Detector = fd.NewDetector(cachedClient, baseRepo.RepoHost()) |
| 180 | } |
| 181 | |
| 182 | projectsV1Support := opts.Detector.ProjectsV1() |
| 183 | issueFeatures, err := opts.Detector.IssueFeatures() |
| 184 | if err != nil { |
| 185 | return err |
| 186 | } |
| 187 | |
| 188 | isTerminal := opts.IO.IsStdoutTTY() |
| 189 | |
| 190 | var milestones []string |
| 191 | if opts.Milestone != "" { |
| 192 | milestones = []string{opts.Milestone} |
| 193 | } |
| 194 | |
| 195 | // Replace special values in assignees |
| 196 | // For web mode, @copilot should be replaced by name; otherwise, login. |
| 197 | assigneeReplacer := prShared.NewSpecialAssigneeReplacer(apiClient, baseRepo.RepoHost(), issueFeatures.ApiActorsSupported, !opts.WebMode) |
| 198 | assignees, err := assigneeReplacer.ReplaceSlice(opts.Assignees) |
| 199 | if err != nil { |
| 200 | return err |
| 201 | } |
| 202 | assigneeSet := set.NewStringSet() |
| 203 | assigneeSet.AddValues(assignees) |
| 204 | |
| 205 | tb := prShared.IssueMetadataState{ |
| 206 | Type: prShared.IssueMetadata, |
| 207 | ApiActorsSupported: issueFeatures.ApiActorsSupported, // TODO ApiActorsSupported |
| 208 | Assignees: assigneeSet.ToSlice(), |
| 209 | Labels: opts.Labels, |
| 210 | ProjectTitles: opts.Projects, |
| 211 | Milestones: milestones, |
| 212 | Title: opts.Title, |
| 213 | Body: opts.Body, |
| 214 | } |
| 215 | |
| 216 | if opts.RecoverFile != "" { |
| 217 | err = prShared.FillFromJSON(opts.IO, opts.RecoverFile, &tb) |
| 218 | if err != nil { |
| 219 | err = fmt.Errorf("failed to recover input: %w", err) |
| 220 | return |