diff --git a/history/information.go b/history/information.go index bc65cac..80d5b5d 100644 --- a/history/information.go +++ b/history/information.go @@ -7,8 +7,10 @@ import ( "regexp" "strconv" "strings" + "time" "github.com/bouncepaw/mycorrhiza/templates" + "github.com/bouncepaw/mycorrhiza/util" ) func RecentChanges(n int) string { @@ -37,8 +39,8 @@ func Revisions(hyphaName string) ([]Revision, error) { var ( out, err = gitsh( "log", "--oneline", "--no-merges", - // Hash, Commiter email, Commiter time, Commit msg separated by tab - "--pretty=format:\"%h\t%ce\t%ct\t%s\"", + // Hash, author email, author time, commit msg separated by tab + "--pretty=format:\"%h\t%ae\t%at\t%s\"", "--", hyphaName+".*", ) revs []Revision @@ -53,6 +55,58 @@ func Revisions(hyphaName string) ([]Revision, error) { return revs, err } +// HistoryWithRevisions returns an html representation of `revs` that is meant to be inserted in a history page. +func HistoryWithRevisions(hyphaName string, revs []Revision) (html string) { + var ( + currentYear int + currentMonth time.Month + ) + for i, rev := range revs { + if rev.Time.Month() != currentMonth || rev.Time.Year() != currentYear { + currentYear = rev.Time.Year() + currentMonth = rev.Time.Month() + if i != 0 { + html += ` + +` + } + html += fmt.Sprintf(` +
+ +

%[3]s

+
+