From 8ce6fdb4d26e4a09b7461806a44e7b444b3ee4a5 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 00:56:52 +0000 Subject: [PATCH] feat: Updated fluere-plugin/src/downloader.rs --- fluere-plugin/src/downloader.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/fluere-plugin/src/downloader.rs b/fluere-plugin/src/downloader.rs index 087d0bc..a869de0 100644 --- a/fluere-plugin/src/downloader.rs +++ b/fluere-plugin/src/downloader.rs @@ -3,6 +3,29 @@ use git2; use std::io; use std::path::Path; +/// Fetch changes from a GitHub repository by `repo_name`. +pub fn fetch_from_github(repo_name: &str) -> Result<(), std::io::Error> { + let url = format!("https://github.com/{}/.git", repo_name); + let path = home_cache_path()?; + let repo_path = path.join(repo_name.split('/').last().unwrap()); + let repository = git2::Repository::open(&repo_path); + + match repository { + Ok(repo) => { + let origin = repo.find_remote("origin"); + match origin { + Ok(mut remote) => { + remote.fetch(&["refs/heads/*:refs/heads/*"], None, None)?; + }, + Err(e) => return Err(e.into()), + } + }, + Err(e) => return Err(e.into()), + } + + Ok(()) +} + pub fn download_plugin_from_github(repo_name: &str) -> Result<(), std::io::Error> { let url = format!("https://github.com/{}", repo_name); let path = home_cache_path()?;