MCPcopy Create free account
hub / github.com/cli/cli / createRun

Function createRun

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

Source from the content-addressed store, hash-verified

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

Callers 3

Test_createRunFunction · 0.70
NewCmdCreateFunction · 0.70

Calls 15

FullNameFunction · 0.92
DetermineEditorFunction · 0.92
NewImmutableSafeURLFunction · 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

Tested by 2

Test_createRunFunction · 0.56