зеркало из https://github.com/mislav/hub.git
Write a message in the editor showing what you're doing.
This commit is contained in:
Родитель
8794caa809
Коммит
43f398e879
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/jingweno/gh/utils"
|
||||
"github.com/jingweno/go-octokit/octokit"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -74,18 +75,19 @@ func release(cmd *Command, args *Args) {
|
|||
runInLocalRepo(func(localRepo *github.GitHubRepo, project *github.Project, gh *github.Client) {
|
||||
currentBranch, err := localRepo.CurrentBranch()
|
||||
utils.Check(err)
|
||||
branchName := currentBranch.ShortName()
|
||||
|
||||
title, body, err := github.GetTitleAndBodyFromFlags(flagReleaseMessage, flagReleaseFile)
|
||||
utils.Check(err)
|
||||
|
||||
if title == "" {
|
||||
title, body, err = github.GetTitleAndBodyFromEditor(nil)
|
||||
title, body, err = writeReleaseTitleAndBody(project, tag, branchName)
|
||||
utils.Check(err)
|
||||
}
|
||||
|
||||
params := octokit.ReleaseParams{
|
||||
TagName: tag,
|
||||
TargetCommitish: currentBranch.ShortName(),
|
||||
TargetCommitish: branchName,
|
||||
Name: title,
|
||||
Body: body,
|
||||
Draft: flagReleaseDraft,
|
||||
|
@ -100,6 +102,20 @@ func release(cmd *Command, args *Args) {
|
|||
})
|
||||
}
|
||||
|
||||
func writeReleaseTitleAndBody(project *github.Project, tag, currentBranch string) (string, string, error) {
|
||||
return github.GetTitleAndBodyFromEditor(func(messageFile string) error {
|
||||
message := `
|
||||
# Creating release %s for %s from %s
|
||||
#
|
||||
# Write a message for this release. The first block
|
||||
# of the text is the title and the rest is description.
|
||||
`
|
||||
message = fmt.Sprintf(message, tag, project.Name, currentBranch)
|
||||
|
||||
return ioutil.WriteFile(messageFile, []byte(message), 0644)
|
||||
})
|
||||
}
|
||||
|
||||
func runInLocalRepo(fn func(localRepo *github.GitHubRepo, project *github.Project, client *github.Client)) {
|
||||
localRepo := github.LocalRepo()
|
||||
project, err := localRepo.CurrentProject()
|
||||
|
|
Загрузка…
Ссылка в новой задаче