From 3f538bf49e1587bdb3faf41e2fe7047d127b5804 Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Mon, 9 Dec 2024 23:23:04 +0000 Subject: [PATCH] style: Fix various code style issues --- src/config.rs | 2 +- src/sources/github_repo.rs | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/config.rs b/src/config.rs index 790edfa..87b2700 100644 --- a/src/config.rs +++ b/src/config.rs @@ -65,7 +65,7 @@ mod tests { #[test] fn deserialize_example_config() { - let args = Args::parse_from(&[ + let args = Args::parse_from([ "github-backup", "--config", &format!( diff --git a/src/sources/github_repo.rs b/src/sources/github_repo.rs index e6b2725..0c4071f 100644 --- a/src/sources/github_repo.rs +++ b/src/sources/github_repo.rs @@ -29,11 +29,11 @@ impl BackupSource for GitHubRepoSource { let target: GitHubRepoSourceKind = policy.from.as_str().parse()?; match target { - GitHubRepoSourceKind::Org(_) if self.artifact_kind == GitHubArtifactKind::Star => return Err(errors::user( + GitHubRepoSourceKind::Org(_) if self.artifact_kind == GitHubArtifactKind::Star => Err(errors::user( "You cannot use an organization as the source for a starred repository backup.", "Either use `from: user` or `from: users/` when using a github/stars source kind.", )), - GitHubRepoSourceKind::Repo(_) if self.artifact_kind == GitHubArtifactKind::Star => return Err(errors::user( + GitHubRepoSourceKind::Repo(_) if self.artifact_kind == GitHubArtifactKind::Star => Err(errors::user( "You cannot use a repository as the source for a starred repository backup.", "Either use `from: user` or `from: users/` when using a github/stars source kind.", )), @@ -83,13 +83,18 @@ impl BackupSource for GitHubRepoSource { tracing_batteries::prelude::debug!("Calling {} to fetch repos", &url); + let refspecs = policy + .properties + .get("refspecs") + .map(|r| r.split(',').map(|r| r.to_string()).collect::>()); + async_stream::try_stream! { if matches!(target, GitHubRepoSourceKind::Repo(_)) { let repo = self.client.get::(url, &policy.credentials, cancel).await?; yield GitRepo::new( repo.full_name.as_str(), repo.clone_url.as_str(), - policy.properties.get("refspecs").map(|r| r.split(",").map(|r| r.to_string()).collect::>())) + refspecs.clone()) .with_credentials(policy.credentials.clone()) .with_metadata_source(&repo); } else { @@ -98,7 +103,7 @@ impl BackupSource for GitHubRepoSource { yield GitRepo::new( repo.full_name.as_str(), repo.clone_url.as_str(), - policy.properties.get("refspecs").map(|r| r.split(",").map(|r| r.to_string()).collect::>())) + refspecs.clone()) .with_credentials(policy.credentials.clone()) .with_metadata_source(&repo); }