MCPcopy Index your code
hub / github.com/cli/cli / createRun

Function createRun

pkg/cmd/issue/create/create.go:163–430  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

161}
162
163func 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

Callers 4

Test_createRunFunction · 0.70
NewCmdCreateFunction · 0.70

Calls 15

ReplaceSliceMethod · 0.95
HasMetadataMethod · 0.95
BodyMethod · 0.95
NameForSubmitMethod · 0.95
TitleMethod · 0.95
NewClientFromHTTPFunction · 0.92
NewCachedHTTPClientFunction · 0.92
NewStringSetFunction · 0.92
GenerateRepoURLFunction · 0.92
DisplayURLFunction · 0.92
FullNameFunction · 0.92
IssueRepoInfoFunction · 0.92

Tested by 3

Test_createRunFunction · 0.56