mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-04-27 15:07:43 +00:00
Extract the first line of the commit message as the title.
This commit is contained in:
parent
6c63be0cfb
commit
b76c164d45
3 changed files with 25 additions and 8 deletions
|
|
@ -3,6 +3,7 @@ package githop
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
|
|
@ -11,16 +12,24 @@ import (
|
||||||
type DigestCommit struct {
|
type DigestCommit struct {
|
||||||
DisplaySHA string
|
DisplaySHA string
|
||||||
URL string
|
URL string
|
||||||
Message *string
|
Title string
|
||||||
|
Message string
|
||||||
Date *time.Time
|
Date *time.Time
|
||||||
RepositoryCommit *github.RepositoryCommit
|
RepositoryCommit *github.RepositoryCommit
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDigestCommit(commit *github.RepositoryCommit, repo *github.Repository) DigestCommit {
|
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{
|
return DigestCommit{
|
||||||
DisplaySHA: (*commit.SHA)[:7],
|
DisplaySHA: (*commit.SHA)[:7],
|
||||||
URL: fmt.Sprintf("https://github.com/%s/commit/%s", *repo.FullName, *commit.SHA),
|
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,
|
Date: commit.Commit.Author.Date,
|
||||||
RepositoryCommit: commit,
|
RepositoryCommit: commit,
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +84,7 @@ func newDigest(githubClient *github.Client) (*Digest, error) {
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
digestStartTime := time.Date(now.Year()-1, now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
|
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.
|
// Only look at repos that may have activity in the digest interval.
|
||||||
var digestRepos []github.Repository
|
var digestRepos []github.Repository
|
||||||
|
|
|
||||||
|
|
@ -49,23 +49,28 @@ dl > div > div {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Commit message */
|
/* Commit message */
|
||||||
|
dl > div > div > h3 {
|
||||||
|
padding: 8px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
dl > div > div > pre {
|
dl > div > div > pre {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 8px;
|
padding: 0 8px 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Commit footer */
|
/* Commit footer */
|
||||||
dl > div > div > pre + div {
|
dl > div > div > div {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-top: solid 1px #ddd;
|
border-top: solid 1px #ddd;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
dl > div > div > pre + div > i {
|
dl > div > div > div > i {
|
||||||
color: #666;
|
color: #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
dl > div > div > pre + div > a {
|
dl > div > div > div > a {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,10 @@
|
||||||
<div>
|
<div>
|
||||||
{{range .Commits }}
|
{{range .Commits }}
|
||||||
<div>
|
<div>
|
||||||
<pre>{{.Message}}</pre>
|
<h3>{{.Title}}</h3>
|
||||||
|
{{if .Message}}
|
||||||
|
<pre>{{.Message}}</pre>
|
||||||
|
{{end}}
|
||||||
<div>
|
<div>
|
||||||
<a href="{{.URL}}">{{.DisplaySHA}}</a>
|
<a href="{{.URL}}">{{.DisplaySHA}}</a>
|
||||||
<i>{{.Date}}</i>
|
<i>{{.Date}}</i>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue