From 7d61e57aa6a7f3e61eb4ceac2b6fd7104245c3fe Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 30 May 2021 15:48:38 +0200 Subject: main::mirror: Take a `github::Repo` instead of repo attribute arguments I wanted to move `clone_path` into `mirror()` so I could make a different clone path for forks. --- src/main.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 89473ea..162c743 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,8 +57,6 @@ async fn main() { for repo in test_repos { let id = repo.id; - let clone_path = Path::new("/tmp") - .join(format!("{}.git", repo.name)); let db_repo = database::Repo::from(&repo); match db.repo_get(id).await { @@ -71,11 +69,7 @@ async fn main() { }, Err(database::Error::Db(sqlx::Error::RowNotFound)) => { - mirror( - &repo.git_url, - &clone_path, - repo.description.as_deref(), - ).unwrap(); + mirror(&repo).unwrap(); db.repo_insert(db_repo).await.unwrap(); }, @@ -86,16 +80,19 @@ async fn main() { } -fn mirror>( - url: &str, - clone_path: P, - description: Option<&str>, -) -> Result<(), Box> { +fn mirror(repo: &github::Repo) -> Result<(), Box> { // mirror database // update description // copy cgitrc - git::mirror(url, clone_path, description)?; + let clone_path = Path::new("/tmp") + .join(format!("{}.git", repo.name)); + + git::mirror( + &repo.git_url, + &clone_path, + repo.description.as_deref(), + )?; Ok(()) } -- cgit v1.2.3