mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
parent
f768c27f0d
commit
11e5d456e8
5 changed files with 54 additions and 24 deletions
|
@ -38,6 +38,7 @@ type changeLog struct {
|
|||
Fixes map[string]gitInfos
|
||||
Notes gitInfos
|
||||
All gitInfos
|
||||
Docs gitInfos
|
||||
|
||||
// Overall stats
|
||||
Repo *gitHubRepo
|
||||
|
@ -45,11 +46,12 @@ type changeLog struct {
|
|||
ThemeCount int
|
||||
}
|
||||
|
||||
func newChangeLog(infos gitInfos) *changeLog {
|
||||
func newChangeLog(infos, docInfos gitInfos) *changeLog {
|
||||
return &changeLog{
|
||||
Enhancements: make(map[string]gitInfos),
|
||||
Fixes: make(map[string]gitInfos),
|
||||
All: infos,
|
||||
Docs: docInfos,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,8 +80,8 @@ func (l *changeLog) addGitInfo(isFix bool, info gitInfo, category string) {
|
|||
segment[category] = infos
|
||||
}
|
||||
|
||||
func gitInfosToChangeLog(infos gitInfos) *changeLog {
|
||||
log := newChangeLog(infos)
|
||||
func gitInfosToChangeLog(infos, docInfos gitInfos) *changeLog {
|
||||
log := newChangeLog(infos, docInfos)
|
||||
for _, info := range infos {
|
||||
los := strings.ToLower(info.Subject)
|
||||
isFix := strings.Contains(los, "fix")
|
||||
|
@ -154,8 +156,8 @@ func git(args ...string) (string, error) {
|
|||
return string(out), nil
|
||||
}
|
||||
|
||||
func getGitInfos(tag string, remote bool) (gitInfos, error) {
|
||||
return getGitInfosBefore("HEAD", tag, remote)
|
||||
func getGitInfos(tag, repoPath string, remote bool) (gitInfos, error) {
|
||||
return getGitInfosBefore("HEAD", tag, repoPath, remote)
|
||||
}
|
||||
|
||||
type countribCount struct {
|
||||
|
@ -211,11 +213,11 @@ func (g gitInfos) ContribCountPerAuthor() contribCounts {
|
|||
return c
|
||||
}
|
||||
|
||||
func getGitInfosBefore(ref, tag string, remote bool) (gitInfos, error) {
|
||||
func getGitInfosBefore(ref, tag, repoPath string, remote bool) (gitInfos, error) {
|
||||
|
||||
var g gitInfos
|
||||
|
||||
log, err := gitLogBefore(ref, tag)
|
||||
log, err := gitLogBefore(ref, tag, repoPath)
|
||||
if err != nil {
|
||||
return g, err
|
||||
}
|
||||
|
@ -246,7 +248,7 @@ func getGitInfosBefore(ref, tag string, remote bool) (gitInfos, error) {
|
|||
// Ignore autogenerated commits etc. in change log. This is a regexp.
|
||||
const ignoredCommits = "releaser?:|snapcraft:|Merge commit|Squashed|Revert"
|
||||
|
||||
func gitLogBefore(ref, tag string) (string, error) {
|
||||
func gitLogBefore(ref, tag, repoPath string) (string, error) {
|
||||
var prevTag string
|
||||
var err error
|
||||
if tag != "" {
|
||||
|
@ -257,7 +259,18 @@ func gitLogBefore(ref, tag string) (string, error) {
|
|||
return "", err
|
||||
}
|
||||
}
|
||||
log, err := git("log", "-E", fmt.Sprintf("--grep=%s", ignoredCommits), "--invert-grep", "--pretty=format:%x1e%h%x1f%aE%x1f%s%x1f%b", "--abbrev-commit", prevTag+".."+ref)
|
||||
|
||||
defaultArgs := []string{"log", "-E", fmt.Sprintf("--grep=%s", ignoredCommits), "--invert-grep", "--pretty=format:%x1e%h%x1f%aE%x1f%s%x1f%b", "--abbrev-commit", prevTag + ".." + ref}
|
||||
|
||||
var args []string
|
||||
|
||||
if repoPath != "" {
|
||||
args = append([]string{"-C", repoPath}, defaultArgs...)
|
||||
} else {
|
||||
args = defaultArgs
|
||||
}
|
||||
|
||||
log, err := git(args...)
|
||||
if err != nil {
|
||||
return ",", err
|
||||
}
|
||||
|
@ -270,7 +283,7 @@ func gitVersionTagBefore(ref string) (string, error) {
|
|||
}
|
||||
|
||||
func gitLog() (string, error) {
|
||||
return gitLogBefore("HEAD", "")
|
||||
return gitLogBefore("HEAD", "", "")
|
||||
}
|
||||
|
||||
func gitShort(args ...string) (output string, err error) {
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
func TestGitInfos(t *testing.T) {
|
||||
skipIfCI(t)
|
||||
infos, err := getGitInfos("v0.20", false)
|
||||
infos, err := getGitInfos("v0.20", "", false)
|
||||
|
||||
require.NoError(t, err)
|
||||
require.True(t, len(infos) > 0)
|
||||
|
|
|
@ -34,7 +34,7 @@ const (
|
|||
releaseNotesMarkdownTemplate = `
|
||||
{{- $patchRelease := isPatch . -}}
|
||||
{{- $contribsPerAuthor := .All.ContribCountPerAuthor -}}
|
||||
|
||||
{{- $docsContribsPerAuthor := .Docs.ContribCountPerAuthor -}}
|
||||
{{- if $patchRelease }}
|
||||
{{ if eq (len .All) 1 }}
|
||||
This is a bug-fix release with one important fix.
|
||||
|
@ -53,6 +53,16 @@ This release represents **{{ len .All }} contributions by {{ len $contribsPerAut
|
|||
{{- $u1.AuthorLink }} leads the Hugo development with a significant amount of contributions, but also a big shoutout to {{ $u2.AuthorLink }}, {{ $u3.AuthorLink }}, and {{ $u4.AuthorLink }} for their ongoing contributions.
|
||||
And as always a big thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) for his relentless work on keeping the documentation and the themes site in pristine condition.
|
||||
{{ end }}
|
||||
{{- if not $patchRelease }}
|
||||
Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs),
|
||||
which has received **{{ len .Docs }} contributions by {{ len $docsContribsPerAuthor }} contributors**.
|
||||
{{- if gt (len $docsContribsPerAuthor) 3 -}}
|
||||
{{- $u1 := index $docsContribsPerAuthor 0 -}}
|
||||
{{- $u2 := index $docsContribsPerAuthor 1 -}}
|
||||
{{- $u3 := index $docsContribsPerAuthor 2 -}}
|
||||
{{- $u4 := index $docsContribsPerAuthor 3 }} A special thanks to {{ $u1.AuthorLink }}, {{ $u2.AuthorLink }}, {{ $u3.AuthorLink }}, and {{ $u4.AuthorLink }} for their work on the documentation site.
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
Hugo now has:
|
||||
|
||||
{{ with .Repo -}}
|
||||
|
@ -61,7 +71,7 @@ Hugo now has:
|
|||
{{- end -}}
|
||||
{{ with .ThemeCount }}
|
||||
* {{ . }}+ [themes](http://themes.gohugo.io/)
|
||||
{{- end }}
|
||||
{{ end }}
|
||||
{{ with .Notes }}
|
||||
## Notes
|
||||
{{ template "change-section" . }}
|
||||
|
@ -128,8 +138,8 @@ var templateFuncs = template.FuncMap{
|
|||
},
|
||||
}
|
||||
|
||||
func writeReleaseNotes(version string, infos gitInfos, to io.Writer) error {
|
||||
changes := gitInfosToChangeLog(infos)
|
||||
func writeReleaseNotes(version string, infosMain, infosDocs gitInfos, to io.Writer) error {
|
||||
changes := gitInfosToChangeLog(infosMain, infosDocs)
|
||||
changes.Version = version
|
||||
repo, err := fetchRepo()
|
||||
if err == nil {
|
||||
|
@ -165,7 +175,7 @@ func fetchThemeCount() (int, error) {
|
|||
return bytes.Count(b, []byte("submodule")), nil
|
||||
}
|
||||
|
||||
func writeReleaseNotesToTmpFile(version string, infos gitInfos) (string, error) {
|
||||
func writeReleaseNotesToTmpFile(version string, infosMain, infosDocs gitInfos) (string, error) {
|
||||
f, err := ioutil.TempFile("", "hugorelease")
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -173,7 +183,7 @@ func writeReleaseNotesToTmpFile(version string, infos gitInfos) (string, error)
|
|||
|
||||
defer f.Close()
|
||||
|
||||
if err := writeReleaseNotes(version, infos, f); err != nil {
|
||||
if err := writeReleaseNotes(version, infosMain, infosDocs, f); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
@ -188,7 +198,7 @@ func getReleaseNotesDocsTempFilename(version string) string {
|
|||
return filepath.Join(getReleaseNotesDocsTempDirAndName(version))
|
||||
}
|
||||
|
||||
func (r *ReleaseHandler) writeReleaseNotesToTemp(version string, infos gitInfos) (string, error) {
|
||||
func (r *ReleaseHandler) writeReleaseNotesToTemp(version string, infosMain, infosDocs gitInfos) (string, error) {
|
||||
|
||||
docsTempPath, name := getReleaseNotesDocsTempDirAndName(version)
|
||||
|
||||
|
@ -214,7 +224,7 @@ func (r *ReleaseHandler) writeReleaseNotesToTemp(version string, infos gitInfos)
|
|||
w = os.Stdout
|
||||
}
|
||||
|
||||
if err := writeReleaseNotes(version, infos, w); err != nil {
|
||||
if err := writeReleaseNotes(version, infosMain, infosDocs, w); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
|
|
@ -34,10 +34,10 @@ func _TestReleaseNotesWriter(t *testing.T) {
|
|||
var b bytes.Buffer
|
||||
|
||||
// TODO(bep) consider to query GitHub directly for the gitlog with author info, probably faster.
|
||||
infos, err := getGitInfosBefore("HEAD", "v0.20", false)
|
||||
infos, err := getGitInfosBefore("HEAD", "v0.20", "", false)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.NoError(t, writeReleaseNotes("0.21", infos, &b))
|
||||
require.NoError(t, writeReleaseNotes("0.21", infos, infos, &b))
|
||||
|
||||
fmt.Println(b.String())
|
||||
|
||||
|
|
|
@ -130,17 +130,24 @@ func (r *ReleaseHandler) Run() error {
|
|||
}
|
||||
}
|
||||
|
||||
var gitCommits gitInfos
|
||||
var (
|
||||
gitCommits gitInfos
|
||||
gitCommitsDocs gitInfos
|
||||
)
|
||||
|
||||
if r.shouldPrepareReleasenotes() || r.shouldRelease() {
|
||||
gitCommits, err = getGitInfos(changeLogFromTag, !r.try)
|
||||
gitCommits, err = getGitInfos(changeLogFromTag, "", !r.try)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gitCommitsDocs, err = getGitInfos(changeLogFromTag, "../hugoDocs", !r.try)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if r.shouldPrepareReleasenotes() {
|
||||
releaseNotesFile, err := r.writeReleaseNotesToTemp(version, gitCommits)
|
||||
releaseNotesFile, err := r.writeReleaseNotesToTemp(version, gitCommits, gitCommitsDocs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue