Skip to content

Commit

Permalink
skip failing repositories to clone
Browse files Browse the repository at this point in the history
  • Loading branch information
kobtea committed Jan 5, 2023
1 parent 55500e2 commit 81883d1
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions fetch/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func newClient(ctx context.Context, option *githubOption) (*github.Client, error
}

func fetchUserRepositories(ctx context.Context, storage *storage.Storage, name string, regexes []*config.Regexp, ghClient *github.Client, ghOption *githubOption) error {
logger := log.GetLogger().Named("fetch.user")
opt := &github.RepositoryListOptions{}
for {
repos, resp, err := ghClient.Repositories.List(ctx, name, opt)
Expand All @@ -100,16 +101,17 @@ func fetchUserRepositories(ctx context.Context, storage *storage.Storage, name s
if r.UsedWithRepo {
j, err := json.Marshal(repo)
if err != nil {
return err
}
if err := storage.UpdateRepoMetadata(ghOption.domain, name, *repo.Name, j); err != nil {
return err
logger.Warnf("failed to marshal metadata: %s/%s/%s: %s", ghOption.domain, name, *repo.Name, err.Error())
} else {
if err := storage.UpdateRepoMetadata(ghOption.domain, name, *repo.Name, j); err != nil {
logger.Warnf("failed to update metadata: %s/%s/%s: %s", ghOption.domain, name, *repo.Name, err.Error())
}
}
}
// source
if r.UsedWithSrc {
if err := storage.UpdateSource(ghOption.domain, name, *repo.Name, *repo.CloneURL, ghOption.tokenEnvvarName); err != nil {
return err
logger.Warnf("failed to update source: %s/%s/%s: %s", ghOption.domain, name, *repo.Name, err.Error())
}
}
}
Expand All @@ -124,6 +126,7 @@ func fetchUserRepositories(ctx context.Context, storage *storage.Storage, name s
}

func fetchOrgRepositories(ctx context.Context, storage *storage.Storage, name string, regexes []*config.Regexp, ghClient *github.Client, ghOption *githubOption) error {
logger := log.GetLogger().Named("fetch.org")
opt := &github.RepositoryListByOrgOptions{}
for {
repos, resp, err := ghClient.Repositories.ListByOrg(ctx, name, opt)
Expand All @@ -137,16 +140,17 @@ func fetchOrgRepositories(ctx context.Context, storage *storage.Storage, name st
if r.UsedWithRepo {
j, err := json.Marshal(repo)
if err != nil {
return err
}
if err := storage.UpdateRepoMetadata(ghOption.domain, name, *repo.Name, j); err != nil {
return err
logger.Warnf("failed to marshal metadata: %s/%s/%s: %s", ghOption.domain, name, *repo.Name, err.Error())
} else {
if err := storage.UpdateRepoMetadata(ghOption.domain, name, *repo.Name, j); err != nil {
logger.Warnf("failed to update metadata: %s/%s/%s: %s", ghOption.domain, name, *repo.Name, err.Error())
}
}
}
// source
if r.UsedWithSrc {
if err := storage.UpdateSource(ghOption.domain, name, *repo.Name, *repo.CloneURL, ghOption.tokenEnvvarName); err != nil {
return err
logger.Warnf("failed to update source: %s/%s/%s: %s", ghOption.domain, name, *repo.Name, err.Error())
}
}
}
Expand Down

0 comments on commit 81883d1

Please sign in to comment.