Show timestamps that the commit was pushed to GitHub.

That matches the timestamp filtering better. The author timestamp is shown in a
tooltip.
This commit is contained in:
Mihai Parparita 2014-08-04 23:01:22 -07:00
parent fe11e2a97a
commit faf41a425d
2 changed files with 23 additions and 6 deletions

View file

@ -9,12 +9,18 @@ import (
"github.com/google/go-github/github"
)
const (
DisplayDateFormat = "3:04pm"
DisplayDateTooltipFormat = "Monday January 2 3:04pm"
)
type DigestCommit struct {
DisplaySHA string
URL string
Title string
Message string
Date time.Time
PushDate time.Time
CommitDate time.Time
RepositoryCommit *github.RepositoryCommit
}
@ -30,13 +36,24 @@ func newDigestCommit(commit *github.RepositoryCommit, repo *github.Repository, l
URL: fmt.Sprintf("https://github.com/%s/commit/%s", *repo.FullName, *commit.SHA),
Title: title,
Message: message,
Date: commit.Commit.Author.Date.In(location),
PushDate: commit.Commit.Committer.Date.In(location),
CommitDate: commit.Commit.Author.Date.In(location),
RepositoryCommit: commit,
}
}
func (commit DigestCommit) DisplayDate() string {
return commit.Date.Format("3:04pm")
// Prefer the date the comit was pushed, since that's what GitHub filters
// and sorts by.
return commit.PushDate.Format(DisplayDateFormat)
}
func (commit DigestCommit) DisplayDateTooltip() string {
// But show the full details in a tooltip
return fmt.Sprintf(
"Pushed at %s\nCommited at %s",
commit.PushDate.Format(DisplayDateTooltipFormat),
commit.CommitDate.Format(DisplayDateTooltipFormat))
}
type RepoDigest struct {
@ -123,8 +140,8 @@ func (digest *Digest) fetch(repos []github.Repository, githubClient *github.Clie
*repo.Name,
&github.CommitsListOptions{
Author: *digest.User.Login,
Since: digest.StartTime,
Until: digest.EndTime,
Since: digest.StartTime.UTC(),
Until: digest.EndTime.UTC(),
})
if err != nil {
ch <- &RepoDigestResponse{nil, err}

View file

@ -20,7 +20,7 @@
{{end}}
<div>
<a href="{{.URL}}">{{.DisplaySHA}}</a>
<i>{{.DisplayDate}}</i>
<i title={{.DisplayDateTooltip}}>{{.DisplayDate}}</i>
</div>
</div>
{{end}}