Skip to content

Commit

Permalink
Pass progress everywhere, for now just to discard it
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jun 30, 2020
1 parent 0eeb6d7 commit da3ae1c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions git-features/src/progress/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,19 @@ pub use self::log::LogProgress;

#[cfg(feature = "progress-prodash")]
mod prodash;

pub struct DiscardProgress;

impl Progress for DiscardProgress {
type SubProgress = DiscardProgress;

fn add_child(&mut self, _name: impl Into<String>) -> Self::SubProgress {
DiscardProgress
}

fn init(&mut self, _max: Option<u32>, _unit: Option<&'static str>) {}

fn set(&mut self, _step: u32) {}

fn message(&mut self, _level: MessageLevel, _message: impl Into<String>) {}
}
1 change: 1 addition & 0 deletions git-odb/src/pack/index/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl index::File {
pub fn verify_checksum_of_index(
&self,
pack: Option<&pack::File>,
_progress: Option<impl git_features::progress::Progress>,
) -> Result<git_object::Id, ChecksumError> {
use crate::pack::{cache, ResolvedBase};
use git_features::parallel::{self, in_parallel_if};
Expand Down
7 changes: 5 additions & 2 deletions git-odb/tests/pack/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ mod method {
}
}

use git_features::progress::DiscardProgress;
#[test]
fn pack_lookup() {
for (index_path, pack_path) in &[
Expand All @@ -114,7 +115,8 @@ fn pack_lookup() {
assert_eq!(pack.kind(), pack::Kind::V2);
assert_eq!(pack.num_objects(), idx.num_objects());
assert_eq!(
idx.verify_checksum_of_index(Some(&pack)).unwrap(),
idx.verify_checksum_of_index(Some(&pack), DiscardProgress.into())
.unwrap(),
idx.checksum_of_index()
);
for idx_entry in idx.iter() {
Expand Down Expand Up @@ -157,7 +159,8 @@ fn iter() {
assert_eq!(idx.version(), *version);
assert_eq!(idx.num_objects(), *num_objects);
assert_eq!(
idx.verify_checksum_of_index(None).unwrap(),
idx.verify_checksum_of_index(None, DiscardProgress.into())
.unwrap(),
idx.checksum_of_index()
);
assert_eq!(idx.checksum_of_index(), hex_to_id(index_checksum));
Expand Down
1 change: 1 addition & 0 deletions gitoxide-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ test = false
[dependencies]
git-repository = { version = "0.1.0", path = "../git-repository" }
git-odb = { version = "0.1.0", path = "../git-odb" }
git-features = { version = "0.1.0", path = "../git-features" }
anyhow = "1.0.31"
3 changes: 2 additions & 1 deletion gitoxide-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub fn init() -> Result<()> {

pub fn verify_pack_or_pack_index(
path: impl AsRef<Path>,
progress: Option<impl git_features::progress::Progress>,
mut out: impl io::Write,
mut err: impl io::Write,
) -> Result<()> {
Expand All @@ -29,7 +30,7 @@ pub fn verify_pack_or_pack_index(
Err(e)
})
.ok();
idx.verify_checksum_of_index(pack.as_ref())?;
idx.verify_checksum_of_index(pack.as_ref(), progress)?;
}
ext => {
return Err(anyhow!(
Expand Down
3 changes: 2 additions & 1 deletion src/plumbing/pretty.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::Result;
use git_features::progress::DiscardProgress;
use gitoxide_core as core;
use std::io::{stderr, stdout};
use structopt::StructOpt;
Expand Down Expand Up @@ -33,7 +34,7 @@ pub fn main() -> Result<()> {
let args = Args::from_args();
match args.cmd {
Subcommands::VerifyPack { path } => {
core::verify_pack_or_pack_index(path, stdout(), stderr())
core::verify_pack_or_pack_index(path, DiscardProgress.into(), stdout(), stderr())
}
}?;
Ok(())
Expand Down

0 comments on commit da3ae1c

Please sign in to comment.