diff options
| author | Teddy Wing | 2021-05-30 15:48:38 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2021-05-30 15:48:38 +0200 | 
| commit | 7d61e57aa6a7f3e61eb4ceac2b6fd7104245c3fe (patch) | |
| tree | 66455f36fde242d38165d9def700da128ae93d89 /src | |
| parent | 25776f714ed5a79d58aeebd902db870d178f8165 (diff) | |
| download | reflectub-7d61e57aa6a7f3e61eb4ceac2b6fd7104245c3fe.tar.bz2 | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 23 | 
1 files changed, 10 insertions, 13 deletions
| 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<P: AsRef<Path>>( -    url: &str, -    clone_path: P, -    description: Option<&str>, -) -> Result<(), Box<dyn std::error::Error>> { +fn mirror(repo: &github::Repo) -> Result<(), Box<dyn std::error::Error>> {      // 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(())  } | 
