aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 697ca7e..144b578 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,9 +1,10 @@
-use anyhow;
+use anyhow::{self, Context};
use sqlx;
use tokio;
use reflectub::{database, git, github};
+use std::fs;
use std::path::{Path, PathBuf};
@@ -71,7 +72,7 @@ async fn main() {
},
Err(database::Error::Db(sqlx::Error::RowNotFound)) => {
- mirror(&path, &repo).unwrap();
+ mirror(&path, &repo, &"./cgitrc".to_owned().into()).unwrap();
db.repo_insert(db_repo).await.unwrap();
},
@@ -100,6 +101,7 @@ fn clone_path<P: AsRef<Path>>(base_path: P, repo: &github::Repo) -> PathBuf {
fn mirror<P: AsRef<Path>>(
clone_path: P,
repo: &github::Repo,
+ base_cgitrc: P,
) -> anyhow::Result<()> {
// mirror database
// update description
@@ -111,6 +113,15 @@ fn mirror<P: AsRef<Path>>(
repo.description(),
)?;
+ // Copy the base cgitrc file into the newly-cloned repository.
+ let cgitrc_path = clone_path.as_ref().join("cgitrc");
+ fs::copy(&base_cgitrc, &cgitrc_path)
+ .with_context(|| format!(
+ "unable to copy '{}' to '{}'",
+ "./cgitrc",
+ &cgitrc_path.display(),
+ ))?;
+
Ok(())
}