mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-04-27 15:07:43 +00:00
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:
parent
fe11e2a97a
commit
faf41a425d
2 changed files with 23 additions and 6 deletions
|
|
@ -9,12 +9,18 @@ import (
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DisplayDateFormat = "3:04pm"
|
||||||
|
DisplayDateTooltipFormat = "Monday January 2 3:04pm"
|
||||||
|
)
|
||||||
|
|
||||||
type DigestCommit struct {
|
type DigestCommit struct {
|
||||||
DisplaySHA string
|
DisplaySHA string
|
||||||
URL string
|
URL string
|
||||||
Title string
|
Title string
|
||||||
Message string
|
Message string
|
||||||
Date time.Time
|
PushDate time.Time
|
||||||
|
CommitDate time.Time
|
||||||
RepositoryCommit *github.RepositoryCommit
|
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),
|
URL: fmt.Sprintf("https://github.com/%s/commit/%s", *repo.FullName, *commit.SHA),
|
||||||
Title: title,
|
Title: title,
|
||||||
Message: message,
|
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,
|
RepositoryCommit: commit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (commit DigestCommit) DisplayDate() string {
|
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 {
|
type RepoDigest struct {
|
||||||
|
|
@ -123,8 +140,8 @@ func (digest *Digest) fetch(repos []github.Repository, githubClient *github.Clie
|
||||||
*repo.Name,
|
*repo.Name,
|
||||||
&github.CommitsListOptions{
|
&github.CommitsListOptions{
|
||||||
Author: *digest.User.Login,
|
Author: *digest.User.Login,
|
||||||
Since: digest.StartTime,
|
Since: digest.StartTime.UTC(),
|
||||||
Until: digest.EndTime,
|
Until: digest.EndTime.UTC(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ch <- &RepoDigestResponse{nil, err}
|
ch <- &RepoDigestResponse{nil, err}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
<div>
|
<div>
|
||||||
<a href="{{.URL}}">{{.DisplaySHA}}</a>
|
<a href="{{.URL}}">{{.DisplaySHA}}</a>
|
||||||
<i>{{.DisplayDate}}</i>
|
<i title={{.DisplayDateTooltip}}>{{.DisplayDate}}</i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue