diff options
-rw-r--r-- | pkg/app/handler/maintainer/utils.go | 32 | ||||
-rw-r--r-- | web/templates/maintainer/components/changelog.tmpl | 10 |
2 files changed, 13 insertions, 29 deletions
diff --git a/pkg/app/handler/maintainer/utils.go b/pkg/app/handler/maintainer/utils.go index c59a19f..2602652 100644 --- a/pkg/app/handler/maintainer/utils.go +++ b/pkg/app/handler/maintainer/utils.go @@ -5,7 +5,6 @@ import ( "encoding/hex" "html/template" "net/http" - "soko/pkg/app/handler/packages" "soko/pkg/app/utils" "soko/pkg/models" "sort" @@ -96,34 +95,27 @@ func getAllBugs(packages []*models.Package) []*models.Bug { // GetFuncMap returns the FuncMap used in templates func GetFuncMap() template.FuncMap { return template.FuncMap{ - "contains": strings.Contains, - "replaceall": strings.ReplaceAll, - "tolower": strings.ToLower, - "getAllBugs": getAllBugs, - "formatRestricts": packages.FormatRestricts, - "appendCommits": func(a []*models.Commit, b []*models.Commit) []*models.Commit { - return append(a, b...) + "contains": strings.Contains, + "replaceall": strings.ReplaceAll, + "tolower": strings.ToLower, + "getAllBugs": getAllBugs, + "allCommits": func(packages []*models.Package) (commits []*models.Commit) { + for _, gpackage := range packages { + commits = append(commits, gpackage.Commits...) + } + sort.Slice(commits, func(i, j int) bool { + return commits[i].PrecedingCommits > commits[j].PrecedingCommits + }) + return commits }, "gravatar": func(email string) string { hasher := md5.Sum([]byte(email)) hash := hex.EncodeToString(hasher[:]) return "https://www.gravatar.com/avatar/" + hash + "?s=13&d=retro" }, - "getReverse": func(index int, versions []*models.Version) *models.Version { - return versions[len(versions)-1-index] - }, - "mkSlice": func(args ...interface{}) []interface{} { - return args - }, "add": func(a, b int) int { return a + b }, - "sortCommits": func(commits []*models.Commit) []*models.Commit { - sort.Slice(commits, func(i, j int) bool { - return commits[i].PrecedingCommits > commits[j].PrecedingCommits - }) - return commits - }, "getPullRequests": func(packages []*models.Package) []*models.GithubPullRequest { pullrequestsMap := map[string]*models.GithubPullRequest{} for _, gpackage := range packages { diff --git a/web/templates/maintainer/components/changelog.tmpl b/web/templates/maintainer/components/changelog.tmpl index d8fb281..0afacc0 100644 --- a/web/templates/maintainer/components/changelog.tmpl +++ b/web/templates/maintainer/components/changelog.tmpl @@ -1,15 +1,7 @@ {{- define "changelog" -}} <div class="row"> <div class="col-md-9"> - {{- $commits := (index .Packages 0).Commits -}} - {{- range $key, $value := .Packages -}} - {{if ne $key 0}} - {{$commits = appendCommits $commits $value.Commits}} - {{end}} - {{- end -}} - - {{- $commits = sortCommits $commits -}} - + {{- $commits := allCommits .Packages -}} {{- if $commits }} <div class="col-md-12"> <h3>Latest Commits</h3> |