mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-04-27 15:07:43 +00:00
Move DigestCommit construction to a separate function.
This commit is contained in:
parent
d1982e9d7f
commit
6c63be0cfb
1 changed files with 16 additions and 13 deletions
|
|
@ -16,6 +16,16 @@ type DigestCommit struct {
|
||||||
RepositoryCommit *github.RepositoryCommit
|
RepositoryCommit *github.RepositoryCommit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newDigestCommit(commit *github.RepositoryCommit, repo *github.Repository) DigestCommit {
|
||||||
|
return 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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type RepoDigest struct {
|
type RepoDigest struct {
|
||||||
Repo *github.Repository
|
Repo *github.Repository
|
||||||
Commits []DigestCommit
|
Commits []DigestCommit
|
||||||
|
|
@ -65,7 +75,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, 1)
|
digestEndTime := digestStartTime.AddDate(0, 0, 7)
|
||||||
|
|
||||||
// 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
|
||||||
|
|
@ -106,14 +116,7 @@ func (digest *Digest) fetch(repos []github.Repository, githubClient *github.Clie
|
||||||
} else {
|
} else {
|
||||||
digestCommits := make([]DigestCommit, 0, len(commits))
|
digestCommits := make([]DigestCommit, 0, len(commits))
|
||||||
for i, _ := range commits {
|
for i, _ := range commits {
|
||||||
commit := &commits[i]
|
digestCommits = append(digestCommits, newDigestCommit(&commits[i], &repo))
|
||||||
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}
|
ch <- &RepoDigestResponse{&RepoDigest{&repo, digestCommits}, nil}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue