Extract the first line of the commit message as the title.

This commit is contained in:
Mihai Parparita 2014-08-03 16:00:29 -07:00
parent 6c63be0cfb
commit b76c164d45
3 changed files with 25 additions and 8 deletions

View file

@ -3,6 +3,7 @@ package githop
import (
"fmt"
"sort"
"strings"
"time"
"github.com/google/go-github/github"
@ -11,16 +12,24 @@ import (
type DigestCommit struct {
DisplaySHA string
URL string
Message *string
Title string
Message string
Date *time.Time
RepositoryCommit *github.RepositoryCommit
}
func newDigestCommit(commit *github.RepositoryCommit, repo *github.Repository) DigestCommit {
messagePieces := strings.SplitN(*commit.Commit.Message, "\n", 2)
title := messagePieces[0]
message := ""
if len(messagePieces) == 2 {
message = messagePieces[1]
}
return DigestCommit{
DisplaySHA: (*commit.SHA)[:7],
URL: fmt.Sprintf("https://github.com/%s/commit/%s", *repo.FullName, *commit.SHA),
Message: commit.Commit.Message,
Title: title,
Message: message,
Date: commit.Commit.Author.Date,
RepositoryCommit: commit,
}
@ -75,7 +84,7 @@ func newDigest(githubClient *github.Client) (*Digest, error) {
now := time.Now()
digestStartTime := time.Date(now.Year()-1, now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
digestEndTime := digestStartTime.AddDate(0, 0, 7)
digestEndTime := digestStartTime.AddDate(0, 0, 1)
// Only look at repos that may have activity in the digest interval.
var digestRepos []github.Repository

View file

@ -49,23 +49,28 @@ dl > div > div {
}
/* Commit message */
dl > div > div > h3 {
padding: 8px;
margin: 0;
}
dl > div > div > pre {
margin: 0;
padding: 8px;
padding: 0 8px 8px;
}
/* Commit footer */
dl > div > div > pre + div {
dl > div > div > div {
background: #fff;
border-top: solid 1px #ddd;
padding: 8px;
}
dl > div > div > pre + div > i {
dl > div > div > div > i {
color: #666;
}
dl > div > div > pre + div > a {
dl > div > div > div > a {
font-family: monospace;
float: right;
}

View file

@ -14,7 +14,10 @@
<div>
{{range .Commits }}
<div>
<pre>{{.Message}}</pre>
<h3>{{.Title}}</h3>
{{if .Message}}
<pre>{{.Message}}</pre>
{{end}}
<div>
<a href="{{.URL}}">{{.DisplaySHA}}</a>
<i>{{.Date}}</i>