aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2021-05-30 15:45:13 +0200
committerTeddy Wing2021-05-30 15:45:13 +0200
commit25776f714ed5a79d58aeebd902db870d178f8165 (patch)
treedcc97b765f17aa6dcde23a780f72173101ea6a8e
parent80a1cda7f857dbb2e776253225446351228072fb (diff)
downloadreflectub-25776f714ed5a79d58aeebd902db870d178f8165.tar.bz2
Add repository description when mirroring
Copy the repository description from GitHub into the clone repo.
-rw-r--r--src/git.rs10
-rw-r--r--src/main.rs4
2 files changed, 12 insertions, 2 deletions
diff --git a/src/git.rs b/src/git.rs
index 017aae3..d83d2b6 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -11,8 +11,16 @@ use std::path::Path;
pub fn mirror<P: AsRef<Path>>(
url: &str,
path: P,
+ description: Option<&str>,
) -> Result<(), Box<dyn std::error::Error>> {
- let repo = git2::Repository::init_bare(path)?;
+ let mut repo_init_options = git2::RepositoryInitOptions::new();
+ repo_init_options.bare(true);
+
+ if let Some(d) = description {
+ repo_init_options.description(d);
+ }
+
+ let repo = git2::Repository::init_opts(path, &repo_init_options)?;
let remote_name = "origin";
diff --git a/src/main.rs b/src/main.rs
index 478ffab..89473ea 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -74,6 +74,7 @@ async fn main() {
mirror(
&repo.git_url,
&clone_path,
+ repo.description.as_deref(),
).unwrap();
db.repo_insert(db_repo).await.unwrap();
@@ -88,12 +89,13 @@ async fn main() {
fn mirror<P: AsRef<Path>>(
url: &str,
clone_path: P,
+ description: Option<&str>,
) -> Result<(), Box<dyn std::error::Error>> {
// mirror database
// update description
// copy cgitrc
- git::mirror(url, clone_path)?;
+ git::mirror(url, clone_path, description)?;
Ok(())
}