Skip to content

Commit

Permalink
lib: accept the verbose flag during upgrading
Browse files Browse the repository at this point in the history
This commit pass down the verbose running information down
to the upgrade method of the repository.

Changelog-Added: lib: accept the verbose flag during upgrading
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Feb 6, 2024
1 parent 4348540 commit fc0fc54
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion coffee_core/src/coffee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl PluginManager for CoffeeManager {
.get_mut(repo)
.ok_or_else(|| error!("Repository with name: `{}` not found", repo))?;

let status = repository.upgrade(&self.config.plugins).await?;
let status = repository.upgrade(&self.config.plugins, verbose).await?;
for plugins in status.plugins_effected.iter() {
self.remove(plugins).await?;
self.install(plugins, verbose, false).await?;
Expand Down
8 changes: 6 additions & 2 deletions coffee_github/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ impl Repository for Github {
}
}

async fn upgrade(&mut self, plugins: &Vec<Plugin>) -> Result<CoffeeUpgrade, CoffeeError> {
async fn upgrade(
&mut self,
plugins: &Vec<Plugin>,
verbose: bool,
) -> Result<CoffeeUpgrade, CoffeeError> {
// get the list of the plugins installed from this repository
// TODO: add a field of installed plugins in the repository struct instead
let mut plugins_effected: Vec<String> = vec![];
Expand All @@ -252,7 +256,7 @@ impl Repository for Github {
}
}
// pull the changes from the repository
let status = git_upgrade(&self.url.path_string, &self.branch).await?;
let status = git_upgrade(&self.url.path_string, &self.branch, verbose).await?;
self.git_head = Some(status.commit_id());
self.last_activity = Some(status.date());
Ok(CoffeeUpgrade {
Expand Down
6 changes: 5 additions & 1 deletion coffee_github/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ pub async fn clone_recursive_fix(repo: git2::Repository, url: &URL) -> Result<()
Ok(())
}

pub async fn git_upgrade(path: &str, branch: &str) -> Result<UpgradeStatus, CoffeeError> {
pub async fn git_upgrade(
path: &str,
branch: &str,
verbose: bool,
) -> Result<UpgradeStatus, CoffeeError> {
use tokio::process::Command;

let repo = git2::Repository::open(path).map_err(|err| error!("{}", err.message()))?;
Expand Down
6 changes: 5 additions & 1 deletion coffee_lib/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ pub trait Repository: Any {
async fn list(&self) -> Result<Vec<Plugin>, CoffeeError>;

/// upgrade the repository
async fn upgrade(&mut self, plugins: &Vec<Plugin>) -> Result<CoffeeUpgrade, CoffeeError>;
async fn upgrade(
&mut self,
plugins: &Vec<Plugin>,
verbose: bool,
) -> Result<CoffeeUpgrade, CoffeeError>;

/// recover the repository from the commit id.
async fn recover(&mut self) -> Result<(), CoffeeError>;
Expand Down

0 comments on commit fc0fc54

Please sign in to comment.