Skip to content

Commit d276cf5

Browse files
lib: accept the verbose flag during upgrading
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]>
1 parent 7cf909e commit d276cf5

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

coffee_core/src/coffee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl PluginManager for CoffeeManager {
351351
.get_mut(repo)
352352
.ok_or_else(|| error!("Repository with name: `{}` not found", repo))?;
353353

354-
let status = repository.upgrade(&self.config.plugins).await?;
354+
let status = repository.upgrade(&self.config.plugins, verbose).await?;
355355
for plugins in status.plugins_effected.iter() {
356356
self.remove(plugins).await?;
357357
self.install(plugins, verbose, false).await?;

coffee_github/src/repository.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ impl Repository for Github {
230230
}
231231
}
232232

233-
async fn upgrade(&mut self, plugins: &Vec<Plugin>) -> Result<CoffeeUpgrade, CoffeeError> {
233+
async fn upgrade(
234+
&mut self,
235+
plugins: &Vec<Plugin>,
236+
verbose: bool,
237+
) -> Result<CoffeeUpgrade, CoffeeError> {
234238
// get the list of the plugins installed from this repository
235239
// TODO: add a field of installed plugins in the repository struct instead
236240
let mut plugins_effected: Vec<String> = vec![];
@@ -252,7 +256,7 @@ impl Repository for Github {
252256
}
253257
}
254258
// pull the changes from the repository
255-
let status = git_upgrade(&self.url.path_string, &self.branch).await?;
259+
let status = git_upgrade(&self.url.path_string, &self.branch, verbose).await?;
256260
self.git_head = Some(status.commit_id());
257261
self.last_activity = Some(status.date());
258262
Ok(CoffeeUpgrade {

coffee_github/src/utils.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,19 @@ pub async fn clone_recursive_fix(repo: git2::Repository, url: &URL) -> Result<()
2525
Ok(())
2626
}
2727

28-
pub async fn git_upgrade(path: &str, branch: &str) -> Result<UpgradeStatus, CoffeeError> {
28+
pub async fn git_upgrade(
29+
path: &str,
30+
branch: &str,
31+
verbose: bool,
32+
) -> Result<UpgradeStatus, CoffeeError> {
2933
use tokio::process::Command;
3034

3135
let repo = git2::Repository::open(path).map_err(|err| error!("{}", err.message()))?;
3236

3337
let (local_commit, _) = get_repo_info!(repo);
3438

3539
let cmd = format!("git pull origin {branch}");
36-
sh!(path, cmd);
40+
sh!(path, cmd, verbose);
3741

3842
let (upstream_commit, date) = get_repo_info!(repo);
3943

coffee_lib/src/repository.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ pub trait Repository: Any {
2525
async fn list(&self) -> Result<Vec<Plugin>, CoffeeError>;
2626

2727
/// upgrade the repository
28-
async fn upgrade(&mut self, plugins: &Vec<Plugin>) -> Result<CoffeeUpgrade, CoffeeError>;
28+
async fn upgrade(
29+
&mut self,
30+
plugins: &Vec<Plugin>,
31+
verbose: bool,
32+
) -> Result<CoffeeUpgrade, CoffeeError>;
2933

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

0 commit comments

Comments
 (0)