Skip to content

Commit

Permalink
Fix: 修复 repo 数据写入为空的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiandongx committed Mar 26, 2022
1 parent 892b421 commit 89eacb6
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions src/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,34 @@ impl RepoFetcher {
let handle = tokio::spawn(async move {
let repos = match config {
GithubConfig::Authenticated(ref config) => {
match GithubRepoFetcher::authenticated_repos(&config).await {
let repos = match GithubRepoFetcher::authenticated_repos(&config).await {
Err(e) => {
println!("Fetch github authenticated repos error: {}", e);
exit(1)
}
Ok(repos) => repos,
};
repos
}
GithubConfig::User(ref config) => {
match GithubRepoFetcher::user_repos(&config).await {
let repos = match GithubRepoFetcher::user_repos(&config).await {
Err(e) => {
println!("Fetch github user repos error: {}", e);
exit(1)
}
Ok(repos) => repos,
};
repos
}
GithubConfig::Org(ref config) => {
match GithubRepoFetcher::org_repos(&config).await {
let repos = match GithubRepoFetcher::org_repos(&config).await {
Err(e) => {
println!("Fetch github user repos error: {}", e);
exit(1)
}
Ok(repos) => repos,
};
repos
}
};

Expand Down Expand Up @@ -168,15 +171,6 @@ impl GithubRepoFetcher {
false
}

fn exclude_filter(
exclude_orgs: &[String],
exclude_repos: &[String],
repo: &Repository,
) -> bool {
Self::exclude_orgs_filter(exclude_orgs, repo)
|| Self::exclude_repos_filter(exclude_repos, repo)
}

async fn authenticated_repos(config: &config::GithubAuthenticated) -> Result<Vec<Repository>> {
let visibility = config.visibility.clone();
let affiliation = config.affiliation.clone();
Expand All @@ -190,11 +184,11 @@ impl GithubRepoFetcher {
.await?
.iter()
.filter(|repo| {
Self::exclude_filter(
&config.clone().exclude_orgs.unwrap_or_default(),
&config.clone().exclude_repos.unwrap_or_default(),
repo,
)
!(Self::exclude_orgs_filter(&config.clone().exclude_orgs.unwrap_or_default(), repo)
|| Self::exclude_repos_filter(
&config.clone().exclude_repos.unwrap_or_default(),
repo,
))
})
.map(|x| x.clone())
.collect::<Vec<_>>();
Expand All @@ -215,7 +209,7 @@ impl GithubRepoFetcher {
.await?
.iter()
.filter(|repo| {
Self::exclude_repos_filter(&config.clone().exclude_repos.unwrap_or_default(), repo)
!Self::exclude_repos_filter(&config.clone().exclude_repos.unwrap_or_default(), repo)
})
.map(|x| x.clone())
.collect::<Vec<_>>();
Expand All @@ -236,7 +230,7 @@ impl GithubRepoFetcher {
.await?
.iter()
.filter(|repo| {
Self::exclude_repos_filter(&config.clone().exclude_repos.unwrap_or_default(), repo)
!Self::exclude_repos_filter(&config.clone().exclude_repos.unwrap_or_default(), repo)
})
.map(|x| x.clone())
.collect::<Vec<_>>();
Expand Down Expand Up @@ -277,7 +271,6 @@ impl GithubRepoFetcher {
}

for repo in response {
println!("{:#?}", repo);
let name = repo.full_name;
repos.push(Repository {
name: name.clone(),
Expand Down

0 comments on commit 89eacb6

Please sign in to comment.