提交 d655819f 编写于 作者: J Jingwen Owen Ou

Make release note comment character configurable

上级 e1d835ca
......@@ -10,6 +10,7 @@ import (
"strings"
"github.com/github/hub/Godeps/_workspace/src/github.com/octokit/go-octokit/octokit"
"github.com/github/hub/git"
"github.com/github/hub/github"
"github.com/github/hub/utils"
)
......@@ -109,7 +110,10 @@ func createRelease(cmd *Command, args *Args) {
var editor *github.Editor
if title == "" {
message := releaseMessage(tag, project.Name, branchName)
cs := git.CommentChar()
message, err := renderReleaseTpl(cs, tag, project.Name, branchName)
utils.Check(err)
editor, err = github.NewEditor("RELEASE", "release", message)
utils.Check(err)
......@@ -158,16 +162,6 @@ func createRelease(cmd *Command, args *Args) {
})
}
func releaseMessage(tag, projectName, currentBranch string) string {
message := `
# Creating release %s for %s from %s
#
# Write a message for this release. The first block
# of text is the title and the rest is description.
`
return fmt.Sprintf(message, tag, projectName, currentBranch)
}
type assetUploader struct {
Client *github.Client
Release *octokit.Release
......
package commands
import (
"bytes"
"text/template"
)
const releaseTmpl = `{{.CS}} Creating release {{.TagName}} for {{.ProjectName}} from {{.BranchName}}
{{.CS}}
{{.CS}} Write a message for this release. The first block
{{.CS}} of text is the title and the rest is description.`
type releaseMsg struct {
CS string
TagName string
ProjectName string
BranchName string
}
func renderReleaseTpl(cs, tagName, projectName, branchName string) (string, error) {
t, err := template.New("releaseTmpl").Parse(releaseTmpl)
if err != nil {
return "", err
}
msg := &releaseMsg{
CS: cs,
TagName: tagName,
ProjectName: projectName,
BranchName: branchName,
}
var b bytes.Buffer
err = t.Execute(&b, msg)
return b.String(), err
}
package commands
import (
"testing"
"github.com/github/hub/Godeps/_workspace/src/github.com/bmizerany/assert"
)
func TestRenderReleaseTpl(t *testing.T) {
msg, err := renderReleaseTpl("#", "1.0", "hub", "master")
assert.Equal(t, nil, err)
expMsg := `# Creating release 1.0 for hub from master
#
# Write a message for this release. The first block
# of text is the title and the rest is description.`
assert.Equal(t, expMsg, msg)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册