Skip to content

Commit

Permalink
feat: Updated fluere-plugin/src/downloader.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Jan 3, 2024
1 parent 9b45d29 commit 8ce6fdb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions fluere-plugin/src/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;

Check failure on line 18 in fluere-plugin/src/downloader.rs

View workflow job for this annotation

GitHub Actions / clippy

`?` couldn't convert the error to `std::io::Error`

error[E0277]: `?` couldn't convert the error to `std::io::Error` --> fluere-plugin/src/downloader.rs:18:77 | 7 | pub fn fetch_from_github(repo_name: &str) -> Result<(), std::io::Error> { | -------------------------- expected `std::io::Error` because of this ... 18 | remote.fetch(&["refs/heads/*:refs/heads/*"], None, None)?; | ^ the trait `std::convert::From<git2::Error>` is not implemented for `std::io::Error` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `std::convert::From<T>`: <std::io::Error as std::convert::From<std::ffi::NulError>> <std::io::Error as std::convert::From<tokio::runtime::blocking::pool::SpawnError>> <std::io::Error as std::convert::From<std::io::IntoInnerError<W>>> <std::io::Error as std::convert::From<tokio::task::JoinError>> <std::io::Error as std::convert::From<std::io::ErrorKind>> <std::io::Error as std::convert::From<tokio::time::error::Elapsed>> = note: required for `std::result::Result<(), std::io::Error>` to implement `std::ops::FromResidual<std::result::Result<std::convert::Infallible, git2::Error>>`
},
Err(e) => return Err(e.into()),

Check failure on line 20 in fluere-plugin/src/downloader.rs

View workflow job for this annotation

GitHub Actions / clippy

the trait bound `std::io::Error: std::convert::From<git2::Error>` is not satisfied

error[E0277]: the trait bound `std::io::Error: std::convert::From<git2::Error>` is not satisfied --> fluere-plugin/src/downloader.rs:20:40 | 20 | Err(e) => return Err(e.into()), | ^^^^ the trait `std::convert::From<git2::Error>` is not implemented for `std::io::Error` | = help: the following other types implement trait `std::convert::From<T>`: <std::io::Error as std::convert::From<std::ffi::NulError>> <std::io::Error as std::convert::From<tokio::runtime::blocking::pool::SpawnError>> <std::io::Error as std::convert::From<std::io::IntoInnerError<W>>> <std::io::Error as std::convert::From<tokio::task::JoinError>> <std::io::Error as std::convert::From<std::io::ErrorKind>> <std::io::Error as std::convert::From<tokio::time::error::Elapsed>> = note: required for `git2::Error` to implement `std::convert::Into<std::io::Error>`
}
},
Err(e) => return Err(e.into()),

Check failure on line 23 in fluere-plugin/src/downloader.rs

View workflow job for this annotation

GitHub Actions / clippy

the trait bound `std::io::Error: std::convert::From<git2::Error>` is not satisfied

error[E0277]: the trait bound `std::io::Error: std::convert::From<git2::Error>` is not satisfied --> fluere-plugin/src/downloader.rs:23:32 | 23 | Err(e) => return Err(e.into()), | ^^^^ the trait `std::convert::From<git2::Error>` is not implemented for `std::io::Error` | = help: the following other types implement trait `std::convert::From<T>`: <std::io::Error as std::convert::From<std::ffi::NulError>> <std::io::Error as std::convert::From<tokio::runtime::blocking::pool::SpawnError>> <std::io::Error as std::convert::From<std::io::IntoInnerError<W>>> <std::io::Error as std::convert::From<tokio::task::JoinError>> <std::io::Error as std::convert::From<std::io::ErrorKind>> <std::io::Error as std::convert::From<tokio::time::error::Elapsed>> = note: required for `git2::Error` to implement `std::convert::Into<std::io::Error>`
}

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()?;
Expand Down

0 comments on commit 8ce6fdb

Please sign in to comment.