releaser: Fix tag detection for changelog when doing a main release

Also improve the changelog slightly.

Fixes #3482
This commit is contained in:
Bjørn Erik Pedersen
2017-05-20 10:58:08 +03:00
committed by GitHub
parent a59525b05b
commit 4d1989d59c
5 changed files with 102 additions and 32 deletions

View File

@@ -24,7 +24,6 @@ import (
"os/exec"
"path/filepath"
"regexp"
"strings"
"github.com/spf13/hugo/helpers"
)
@@ -89,20 +88,31 @@ func (r *ReleaseHandler) Run() error {
tag := "v" + version
// Exit early if tag already exists
out, err := git("tag", "-l", tag)
exists, err := tagExists(tag)
if err != nil {
return err
}
if strings.Contains(out, tag) {
if exists {
return fmt.Errorf("Tag %q already exists", tag)
}
var changeLogFromTag string
if newVersion.PatchLevel == 0 {
// There may have been patch releases inbetween, so set the tag explicitly.
changeLogFromTag = "v" + newVersion.Prev().String()
exists, _ := tagExists(changeLogFromTag)
if !exists {
// fall back to one that exists.
changeLogFromTag = ""
}
}
var gitCommits gitInfos
if r.shouldPrepare() || r.shouldRelease() {
gitCommits, err = getGitInfos(true)
gitCommits, err = getGitInfos(changeLogFromTag, true)
if err != nil {
return err
}