all repos — homestead @ f28244740352b116eb43defb4b12a9656ea532a2

Code for my website

show post changelogs

Alan Pearce
commit

f28244740352b116eb43defb4b12a9656ea532a2

parent

02344e6cb41515516464de403e2eae1caac81e5c

1 file changed, 24 insertions(+), 7 deletions(-)

changed files
M internal/vcs/filelog.gointernal/vcs/filelog.go
@@ -2,12 +2,16 @@ package vcs
import ( "net/url" + "regexp" + "strings" "time" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing/object" "gitlab.com/tozd/go/errors" ) + +const hashLength = 7 type Author struct { Name string
@@ -15,11 +19,14 @@ Email string
} type Commit struct { - Hash string - Message string - Author Author - Date time.Time - Link *url.URL + ShortHash string + Hash string + Message string + Summary string + Description string + Author Author + Date time.Time + Link *url.URL } func (r *Repository) makeCommitURL(hash string) *url.URL {
@@ -45,9 +52,13 @@
defer fl.Close() cs := make([]*Commit, 0) err = fl.ForEach(func(c *object.Commit) error { + summary, description, _ := strings.Cut(c.Message, "\n") cs = append(cs, &Commit{ - Hash: c.Hash.String(), - Message: c.Message, + ShortHash: c.Hash.String()[:hashLength], + Hash: c.Hash.String(), + Message: c.Message, + Summary: summary, + Description: cleanupDescription(description), Author: Author{ Name: c.Author.Name, Email: c.Author.Email,
@@ -64,3 +75,9 @@ }
return cs, nil } + +var rewrap = regexp.MustCompile(`\r?\n(\w)`) + +func cleanupDescription(description string) string { + return strings.TrimSpace(rewrap.ReplaceAllString(description, " $1")) +}