Skip to content

Commit

Permalink
style: Fix various code style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Dec 9, 2024
1 parent fc11aac commit 3f538bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
13 changes: 9 additions & 4 deletions src/sources/github_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ impl BackupSource<GitRepo> 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/<name>` 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/<name>` when using a github/stars source kind.",
)),
Expand Down Expand Up @@ -83,13 +83,18 @@ impl BackupSource<GitRepo> 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::<Vec<String>>());

async_stream::try_stream! {
if matches!(target, GitHubRepoSourceKind::Repo(_)) {
let repo = self.client.get::<GitHubRepo>(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::<Vec<String>>()))
refspecs.clone())
.with_credentials(policy.credentials.clone())
.with_metadata_source(&repo);
} else {
Expand All @@ -98,7 +103,7 @@ impl BackupSource<GitRepo> 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::<Vec<String>>()))
refspecs.clone())
.with_credentials(policy.credentials.clone())
.with_metadata_source(&repo);
}
Expand Down

0 comments on commit 3f538bf

Please sign in to comment.