MCPcopy
hub / github.com/cli/cli / createRun

Function createRun

pkg/cmd/release/create/create.go:227–568  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

225}
226
227func createRun(opts *CreateOptions) error {
228 httpClient, err := opts.HttpClient()
229 if err != nil {
230 return err
231 }
232
233 baseRepo, err := opts.BaseRepo()
234 if err != nil {
235 return err
236 }
237
238 if opts.FailOnNoCommits {
239 isNew, err := isNewRelease(httpClient, baseRepo)
240 if err != nil {
241 return fmt.Errorf("failed to check whether there were new commits since last release: %v", err)
242 }
243 if !isNew {
244 return fmt.Errorf("no new commits since the last release")
245 }
246 }
247
248 var existingTag bool
249 if opts.TagName == "" {
250 tags, err := getTags(httpClient, baseRepo, 5)
251 if err != nil {
252 return err
253 }
254
255 if len(tags) != 0 {
256 options := make([]string, len(tags))
257 for i, tag := range tags {
258 options[i] = tag.Name
259 }
260 createNewTagOption := "Create a new tag"
261 options = append(options, createNewTagOption)
262 selected, err := opts.Prompter.Select("Choose a tag", options[0], options)
263 if err != nil {
264 return fmt.Errorf("could not prompt: %w", err)
265 }
266 tag := options[selected]
267 if tag != createNewTagOption {
268 existingTag = true
269 opts.TagName = tag
270 }
271 }
272
273 if opts.TagName == "" {
274 opts.TagName, err = opts.Prompter.Input("Tag name", "")
275 if err != nil {
276 return fmt.Errorf("could not prompt: %w", err)
277 }
278 opts.TagName = strings.TrimSpace(opts.TagName)
279 }
280 }
281
282 if opts.VerifyTag && !existingTag {
283 remoteTagPresent, err := remoteTagExists(httpClient, baseRepo, opts.TagName)
284 if err != nil {

Callers 3

Test_createRunFunction · 0.70
NewCmdCreateFunction · 0.70

Calls 15

FullNameFunction · 0.92
DetermineEditorFunction · 0.92
ConcurrentUploadFunction · 0.92
isNewReleaseFunction · 0.85
getTagsFunction · 0.85
gitTagInfoFunction · 0.85
generateReleaseNotesFunction · 0.85
changelogForRangeFunction · 0.85
generateChangelogFunction · 0.85
detectPreviousTagFunction · 0.85
publishedReleaseExistsFunction · 0.85
createReleaseFunction · 0.85

Tested by 2

Test_createRunFunction · 0.56