ref: 11e5d456e8bca845a43ba13b39cd26c60d26eb1c
parent: f768c27f0d1a554f36e873a6d8f61628525380c4
author: Bjørn Erik Pedersen <[email protected]>
date: Sun Aug 6 06:42:07 EDT 2017
releaser: Include stats from hugoDocs Fixes #3727
--- a/releaser/git.go
+++ b/releaser/git.go
@@ -38,6 +38,7 @@
Fixes map[string]gitInfos
Notes gitInfos
All gitInfos
+ Docs gitInfos
// Overall stats
Repo *gitHubRepo
@@ -45,11 +46,12 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 gitLog() (string, error) {
- return gitLogBefore("HEAD", "")
+ return gitLogBefore("HEAD", "", "")
}
func gitShort(args ...string) (output string, err error) {
--- a/releaser/git_test.go
+++ b/releaser/git_test.go
@@ -22,7 +22,7 @@
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)
--- a/releaser/releasenotes_writer.go
+++ b/releaser/releasenotes_writer.go
@@ -34,7 +34,7 @@
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 @@
{{- $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 @@
{{- end -}}
{{ with .ThemeCount }}
* {{ . }}+ [themes](http://themes.gohugo.io/)
-{{- end }}
+{{ end }}
{{ with .Notes }}
## Notes
{{ template "change-section" . }}
@@ -128,8 +138,8 @@
},
}
-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 @@
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 @@
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 @@
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 @@
w = os.Stdout
}
- if err := writeReleaseNotes(version, infos, w); err != nil {
+ if err := writeReleaseNotes(version, infosMain, infosDocs, w); err != nil {
return "", err
}
--- a/releaser/releasenotes_writer_test.go
+++ b/releaser/releasenotes_writer_test.go
@@ -34,10 +34,10 @@
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())
--- a/releaser/releaser.go
+++ b/releaser/releaser.go
@@ -130,17 +130,24 @@
}
}
- 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
}