mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-03-25 09:25:49 +00:00
Don't turn errors fetching individual repository intervals into errors for the whole digest.
Return the data that we have, and indicate in a footer which repositories errors were encountered for.
This commit is contained in:
parent
f39b6e5e17
commit
05acf9240a
3 changed files with 26 additions and 7 deletions
|
|
@ -87,6 +87,10 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"errors": {
|
||||
"background": "#fdd",
|
||||
"padding": "10px"
|
||||
},
|
||||
"email-footer": {
|
||||
"color": "#999",
|
||||
"font-size": "9pt",
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ type Digest struct {
|
|||
User *github.User
|
||||
TimezoneLocation *time.Location
|
||||
IntervalDigests []*IntervalDigest
|
||||
RepoErrors map[string]error
|
||||
}
|
||||
|
||||
func newDigest(c appengine.Context, githubClient *github.Client, account *Account) (*Digest, error) {
|
||||
|
|
@ -217,15 +218,20 @@ func newDigest(c appengine.Context, githubClient *github.Client, account *Accoun
|
|||
User: user,
|
||||
TimezoneLocation: account.TimezoneLocation,
|
||||
IntervalDigests: intervalDigests,
|
||||
RepoErrors: make(map[string]error),
|
||||
}
|
||||
|
||||
err = digest.fetch(githubClient)
|
||||
return digest, err
|
||||
digest.fetch(githubClient)
|
||||
for repoFullName, err := range digest.RepoErrors {
|
||||
c.Errorf("Error fetching %s: %s", repoFullName, err.Error())
|
||||
}
|
||||
return digest, nil
|
||||
}
|
||||
|
||||
func (digest *Digest) fetch(githubClient *github.Client) error {
|
||||
func (digest *Digest) fetch(githubClient *github.Client) {
|
||||
type RepoDigestResponse struct {
|
||||
intervalDigest *IntervalDigest
|
||||
repo *Repo
|
||||
repoDigest *RepoDigest
|
||||
err error
|
||||
}
|
||||
|
|
@ -250,7 +256,7 @@ func (digest *Digest) fetch(githubClient *github.Client) error {
|
|||
Until: intervalDigest.EndTime.UTC(),
|
||||
})
|
||||
if err != nil {
|
||||
ch <- &RepoDigestResponse{nil, nil, err}
|
||||
ch <- &RepoDigestResponse{intervalDigest, repo, nil, err}
|
||||
return
|
||||
}
|
||||
commits = append(commits, pageCommits...)
|
||||
|
|
@ -263,7 +269,7 @@ func (digest *Digest) fetch(githubClient *github.Client) error {
|
|||
for i := range commits {
|
||||
digestCommits[len(commits)-i-1] = newDigestCommit(&commits[i], repo, digest.TimezoneLocation)
|
||||
}
|
||||
ch <- &RepoDigestResponse{intervalDigest, &RepoDigest{repo, digestCommits}, nil}
|
||||
ch <- &RepoDigestResponse{intervalDigest, repo, &RepoDigest{repo, digestCommits}, nil}
|
||||
}(intervalDigest, repo)
|
||||
fetchCount++
|
||||
}
|
||||
|
|
@ -272,7 +278,8 @@ func (digest *Digest) fetch(githubClient *github.Client) error {
|
|||
select {
|
||||
case r := <-ch:
|
||||
if r.err != nil {
|
||||
return r.err
|
||||
digest.RepoErrors[*r.repo.FullName] = r.err
|
||||
continue
|
||||
}
|
||||
if len(r.repoDigest.Commits) > 0 {
|
||||
r.intervalDigest.RepoDigests = append(r.intervalDigest.RepoDigests, r.repoDigest)
|
||||
|
|
@ -287,7 +294,6 @@ func (digest *Digest) fetch(githubClient *github.Client) error {
|
|||
}
|
||||
}
|
||||
digest.IntervalDigests = nonEmptyIntervalDigests
|
||||
return nil
|
||||
}
|
||||
|
||||
func (digest *Digest) Empty() bool {
|
||||
|
|
|
|||
|
|
@ -54,6 +54,15 @@
|
|||
|
||||
{{end}}
|
||||
|
||||
{{if .RepoErrors}}
|
||||
<div style="{{style "errors"}}">
|
||||
Errors were encountered for the following repositories:
|
||||
{{range $repoFullName, $error := .RepoErrors}}
|
||||
<a href="https://github.com/{{$repoFullName}}">{{$repoFullName}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
</div>
|
||||
|
||||
{{end}}
|
||||
|
|
|
|||
Loading…
Reference in a new issue