diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/database.rs | 8 | ||||
-rw-r--r-- | src/main.rs | 14 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/database.rs b/src/database.rs index 1dac44f..ac5ef3b 100644 --- a/src/database.rs +++ b/src/database.rs @@ -12,6 +12,14 @@ pub struct Repo { updated_at: Option<String>, } +impl Repo { + pub fn description(&self) -> &str { + self.description + .as_deref() + .unwrap_or("") + } +} + impl From<&github::Repo> for Repo { fn from(repo: &github::Repo) -> Self { Self { diff --git a/src/main.rs b/src/main.rs index 2a3e988..697ca7e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,9 +62,9 @@ async fn main() { let db_repo = database::Repo::from(&repo); match db.repo_get(id).await { - Ok(_) => { + Ok(current_repo) => { if db.repo_is_updated(&db_repo).await.unwrap() { - update(&path, &repo).unwrap(); + update(&path, ¤t_repo, &repo).unwrap(); db.repo_update(&db_repo).await.unwrap(); } @@ -116,12 +116,16 @@ fn mirror<P: AsRef<Path>>( fn update<P: AsRef<Path>>( repo_path: P, - repo: &github::Repo, + current_repo: &database::Repo, + updated_repo: &github::Repo, ) -> anyhow::Result<()> { git::update(&repo_path)?; - // TODO: Don't write if description is the same - git::update_description(&repo_path, repo.description())?; + let remote_description = updated_repo.description(); + + if current_repo.description() != remote_description { + git::update_description(&repo_path, remote_description)?; + } Ok(()) } |