зеркало из 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/gh/utils"
|
||||||
"github.com/jingweno/go-octokit/octokit"
|
"github.com/jingweno/go-octokit/octokit"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -74,18 +75,19 @@ func release(cmd *Command, args *Args) {
|
||||||
runInLocalRepo(func(localRepo *github.GitHubRepo, project *github.Project, gh *github.Client) {
|
runInLocalRepo(func(localRepo *github.GitHubRepo, project *github.Project, gh *github.Client) {
|
||||||
currentBranch, err := localRepo.CurrentBranch()
|
currentBranch, err := localRepo.CurrentBranch()
|
||||||
utils.Check(err)
|
utils.Check(err)
|
||||||
|
branchName := currentBranch.ShortName()
|
||||||
|
|
||||||
title, body, err := github.GetTitleAndBodyFromFlags(flagReleaseMessage, flagReleaseFile)
|
title, body, err := github.GetTitleAndBodyFromFlags(flagReleaseMessage, flagReleaseFile)
|
||||||
utils.Check(err)
|
utils.Check(err)
|
||||||
|
|
||||||
if title == "" {
|
if title == "" {
|
||||||
title, body, err = github.GetTitleAndBodyFromEditor(nil)
|
title, body, err = writeReleaseTitleAndBody(project, tag, branchName)
|
||||||
utils.Check(err)
|
utils.Check(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
params := octokit.ReleaseParams{
|
params := octokit.ReleaseParams{
|
||||||
TagName: tag,
|
TagName: tag,
|
||||||
TargetCommitish: currentBranch.ShortName(),
|
TargetCommitish: branchName,
|
||||||
Name: title,
|
Name: title,
|
||||||
Body: body,
|
Body: body,
|
||||||
Draft: flagReleaseDraft,
|
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)) {
|
func runInLocalRepo(fn func(localRepo *github.GitHubRepo, project *github.Project, client *github.Client)) {
|
||||||
localRepo := github.LocalRepo()
|
localRepo := github.LocalRepo()
|
||||||
project, err := localRepo.CurrentProject()
|
project, err := localRepo.CurrentProject()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче