mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-04-27 15:07:43 +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
|
package githop
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type DigestCommit struct {
|
||||||
|
DisplaySHA string
|
||||||
|
URL string
|
||||||
|
Message *string
|
||||||
|
Date *time.Time
|
||||||
|
RepositoryCommit *github.RepositoryCommit
|
||||||
|
}
|
||||||
|
|
||||||
type RepoDigest struct {
|
type RepoDigest struct {
|
||||||
Repo *github.Repository
|
Repo *github.Repository
|
||||||
Commits []github.RepositoryCommit
|
Commits []DigestCommit
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort.Interface implementation for sorting RepoDigests.
|
// sort.Interface implementation for sorting RepoDigests.
|
||||||
|
|
@ -95,7 +104,18 @@ func (digest *Digest) fetch(repos []github.Repository, githubClient *github.Clie
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ch <- &RepoDigestResponse{nil, err}
|
ch <- &RepoDigestResponse{nil, err}
|
||||||
} else {
|
} 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)
|
}(repo)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@
|
||||||
<div>
|
<div>
|
||||||
{{range .Commits }}
|
{{range .Commits }}
|
||||||
<div>
|
<div>
|
||||||
<pre>{{.Commit.Message}}</pre>
|
<pre>{{.Message}}</pre>
|
||||||
<div>
|
<div>
|
||||||
<a href="https://github.com/{{$repoDigest.Repo.FullName}}/commit/{{.SHA}}">{{.SHA}}</a>
|
<a href="{{.URL}}">{{.DisplaySHA}}</a>
|
||||||
<i>{{.Commit.Author.Date}}</i>
|
<i>{{.Date}}</i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue