mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-03-25 09:25:49 +00:00
Create a DigestCommit struct for extracting interesting/display data for commits.
For just used for convenience storage of properties and a display SHA, but will also be used for message/title extraction.
This commit is contained in:
parent
243cfb06e6
commit
d1982e9d7f
2 changed files with 25 additions and 5 deletions
|
|
@ -1,15 +1,24 @@
|
|||
package githop
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-github/github"
|
||||
)
|
||||
|
||||
type DigestCommit struct {
|
||||
DisplaySHA string
|
||||
URL string
|
||||
Message *string
|
||||
Date *time.Time
|
||||
RepositoryCommit *github.RepositoryCommit
|
||||
}
|
||||
|
||||
type RepoDigest struct {
|
||||
Repo *github.Repository
|
||||
Commits []github.RepositoryCommit
|
||||
Commits []DigestCommit
|
||||
}
|
||||
|
||||
// sort.Interface implementation for sorting RepoDigests.
|
||||
|
|
@ -95,7 +104,18 @@ func (digest *Digest) fetch(repos []github.Repository, githubClient *github.Clie
|
|||
if err != nil {
|
||||
ch <- &RepoDigestResponse{nil, err}
|
||||
} else {
|
||||
ch <- &RepoDigestResponse{&RepoDigest{&repo, commits}, nil}
|
||||
digestCommits := make([]DigestCommit, 0, len(commits))
|
||||
for i, _ := range commits {
|
||||
commit := &commits[i]
|
||||
digestCommits = append(digestCommits, DigestCommit{
|
||||
DisplaySHA: (*commit.SHA)[:7],
|
||||
URL: fmt.Sprintf("https://github.com/%s/commit/%s", *repo.FullName, *commit.SHA),
|
||||
Message: commit.Commit.Message,
|
||||
Date: commit.Commit.Author.Date,
|
||||
RepositoryCommit: commit,
|
||||
})
|
||||
}
|
||||
ch <- &RepoDigestResponse{&RepoDigest{&repo, digestCommits}, nil}
|
||||
}
|
||||
}(repo)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@
|
|||
<div>
|
||||
{{range .Commits }}
|
||||
<div>
|
||||
<pre>{{.Commit.Message}}</pre>
|
||||
<pre>{{.Message}}</pre>
|
||||
<div>
|
||||
<a href="https://github.com/{{$repoDigest.Repo.FullName}}/commit/{{.SHA}}">{{.SHA}}</a>
|
||||
<i>{{.Commit.Author.Date}}</i>
|
||||
<a href="{{.URL}}">{{.DisplaySHA}}</a>
|
||||
<i>{{.Date}}</i>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
|
|||
Loading…
Reference in a new issue