releaser: Include stats from hugoDocs

Fixes #3727
This commit is contained in:
Bjørn Erik Pedersen 2017-08-06 10:42:07 +02:00
parent f768c27f0d
commit 11e5d456e8
5 changed files with 54 additions and 24 deletions

View file

@ -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) {