cli: add a progress spinner to pakker fork init
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Id40f83862483f20e569cbd27d38143f96a6a6964
This commit is contained in:
parent
4f7ff1c2ec
commit
754927c55a
1 changed files with 24 additions and 6 deletions
|
|
@ -3,8 +3,11 @@ use std::{
|
|||
fs,
|
||||
io::Write,
|
||||
path::Path,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
|
||||
use crate::{
|
||||
cli::ForkArgs,
|
||||
error::PakkerError,
|
||||
|
|
@ -270,11 +273,19 @@ fn execute_init(
|
|||
// re-downloading objects
|
||||
let parent_path = Path::new(&parent_path_str);
|
||||
|
||||
println!(
|
||||
let spinner = ProgressBar::new_spinner();
|
||||
spinner.set_style(
|
||||
ProgressStyle::default_spinner()
|
||||
.template("{spinner:.green} {msg}")
|
||||
.expect("spinner template is valid"),
|
||||
);
|
||||
spinner.enable_steady_tick(Duration::from_millis(80));
|
||||
spinner.set_message(format!(
|
||||
"Cloning parent repository from local path {}...",
|
||||
path.display()
|
||||
);
|
||||
));
|
||||
git::clone_repository(&fp, parent_path, &resolved_ref, None)?;
|
||||
spinner.finish_and_clear();
|
||||
|
||||
// Ensure the cloned repo's origin is set to the upstream URL (not the local
|
||||
// path)
|
||||
|
|
@ -317,11 +328,18 @@ fn execute_init(
|
|||
}
|
||||
}
|
||||
|
||||
println!("Cloning parent repository...");
|
||||
println!(" URL: {url}");
|
||||
println!(" Ref: {resolved_ref}");
|
||||
|
||||
let spinner = ProgressBar::new_spinner();
|
||||
spinner.set_style(
|
||||
ProgressStyle::default_spinner()
|
||||
.template("{spinner:.green} {msg}")
|
||||
.expect("spinner template is valid"),
|
||||
);
|
||||
spinner.enable_steady_tick(Duration::from_millis(80));
|
||||
spinner.set_message(format!(
|
||||
"Cloning parent repository: {url} ({resolved_ref})"
|
||||
));
|
||||
git::clone_repository(&url, parent_path, &resolved_ref, None)?;
|
||||
spinner.finish_and_clear();
|
||||
}
|
||||
|
||||
let commit_sha = git::get_commit_sha(parent_path, &resolved_ref)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue