MCPcopy
hub / github.com/mislav/hub / createRelease

Function createRelease

commands/release.go:446–541  ·  view source on GitHub ↗
(cmd *Command, args *Args)

Source from the content-addressed store, hash-verified

444}
445
446func createRelease(cmd *Command, args *Args) {
447 tagName := ""
448 if args.ParamsSize() > 0 {
449 tagName = args.GetParam(0)
450 }
451 if tagName == "" {
452 utils.Check(cmd.UsageError(""))
453 return
454 }
455
456 assetsToUpload, close, err := openAssetFiles(args.Flag.AllValues("--attach"))
457 utils.Check(err)
458 defer close()
459
460 localRepo, err := github.LocalRepo()
461 utils.Check(err)
462
463 project, err := localRepo.MainProject()
464 utils.Check(err)
465
466 gh := github.NewClient(project.Host)
467
468 messageBuilder := &github.MessageBuilder{
469 Filename: "RELEASE_EDITMSG",
470 Title: "release",
471 }
472
473 messageBuilder.AddCommentedSection(fmt.Sprintf(`Creating release %s for %s
474
475Write a message for this release. The first block of
476text is the title and the rest is the description.`, tagName, project))
477
478 flagReleaseMessage := args.Flag.AllValues("--message")
479 if len(flagReleaseMessage) > 0 {
480 messageBuilder.Message = strings.Join(flagReleaseMessage, "\n\n")
481 messageBuilder.Edit = args.Flag.Bool("--edit")
482 } else if args.Flag.HasReceived("--file") {
483 messageBuilder.Message, err = msgFromFile(args.Flag.Value("--file"))
484 utils.Check(err)
485 messageBuilder.Edit = args.Flag.Bool("--edit")
486 } else {
487 messageBuilder.Edit = true
488 }
489
490 title, body, err := messageBuilder.Extract()
491 utils.Check(err)
492
493 if title == "" {
494 utils.Check(fmt.Errorf("Aborting release due to empty release title"))
495 }
496
497 params := &github.Release{
498 TagName: tagName,
499 TargetCommitish: args.Flag.Value("--commitish"),
500 Name: title,
501 Body: body,
502 Draft: args.Flag.Bool("--draft"),
503 Prerelease: args.Flag.Bool("--prerelease"),

Callers

nothing calls this directly

Calls 15

AddCommentedSectionMethod · 0.95
ExtractMethod · 0.95
CreateReleaseMethod · 0.95
CleanupMethod · 0.95
UploadReleaseAssetsMethod · 0.95
CheckFunction · 0.92
LocalRepoFunction · 0.92
NewClientFunction · 0.92
PrintfFunction · 0.92
ErrorfFunction · 0.92
openAssetFilesFunction · 0.85
msgFromFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…