Skip to content

Commit 70989b3

Browse files
committed
Use trait object for progress in PrepareFetch::fetch_only
Signed-off-by: Jiahao XU <[email protected]>
1 parent 1b1fc25 commit 70989b3

File tree

7 files changed

+20
-9
lines changed

7 files changed

+20
-9
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ gix = { version = "^0.53.1", path = "gix", default-features = false }
168168
time = "0.3.23"
169169

170170
clap = { version = "4.1.1", features = ["derive", "cargo"] }
171-
prodash = { version = "26.2.0", optional = true, default-features = false }
171+
prodash = { workspace = true, optional = true }
172172
is-terminal = { version = "0.4.0", optional = true }
173173
env_logger = { version = "0.10.0", default-features = false }
174174
crosstermion = { version = "0.11.0", optional = true, default-features = false }
@@ -292,6 +292,9 @@ members = [
292292
"gix-traverse/tests",
293293
]
294294

295+
[workspace.dependencies]
296+
prodash = { version = "26.2.0", path = "../prodash", default-features = false }
297+
295298
[package.metadata.docs.rs]
296299
features = ["document-features", "max"]
297300
rustdoc-args = ["--cfg", "docsrs"]

gix-features/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ crc32fast = { version = "1.2.1", optional = true }
129129
sha1 = { version = "0.10.0", optional = true }
130130

131131
# progress
132-
prodash = { version = "26.2.0", optional = true, default-features = false }
132+
prodash = { workspace = true, optional = true }
133133
bytesize = { version = "1.0.1", optional = true }
134134

135135
# pipe

gix-features/src/progress.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ pub use prodash::{
99
progress::{
1010
AtomicStep, Discard, DoOrDiscard, Either, Id, Step, StepShared, Task, ThroughputOnDrop, Value, UNKNOWN,
1111
},
12-
unit, Count, DynNestedProgress, NestedProgress, Progress, Unit,
12+
unit, BoxedDynNestedProgress, Count, DynNestedProgress, DynNestedProgressToNestedProgress, NestedProgress,
13+
Progress, Unit,
1314
};
1415
/// A stub for the portions of the `bytesize` crate that we use internally in `gitoxide`.
1516
#[cfg(not(feature = "progress-unit-bytes"))]

gix/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ gix-protocol = { version = "^0.39.0", path = "../gix-protocol", optional = true
243243
gix-transport = { version = "^0.36.0", path = "../gix-transport", optional = true }
244244

245245
# Just to get the progress-tree feature
246-
prodash = { version = "26.2", optional = true, default-features = false, features = ["progress-tree"] }
246+
prodash = { workspace = true, optional = true, features = ["progress-tree"] }
247247
once_cell = "1.14.0"
248248
signal-hook = { version = "0.3.9", default-features = false, optional = true }
249249
thiserror = "1.0.26"

gix/src/clone/fetch/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::clone::PrepareFetch;
1+
use crate::{clone::PrepareFetch, features::progress::DynNestedProgressToNestedProgress};
22

33
/// The error returned by [`PrepareFetch::fetch_only()`].
44
#[derive(Debug, thiserror::Error)]
@@ -58,6 +58,15 @@ impl PrepareFetch {
5858
P: crate::NestedProgress,
5959
P::SubProgress: 'static,
6060
{
61+
self.fetch_only_inner(&mut progress, should_interrupt)
62+
}
63+
64+
#[gix_protocol::maybe_async::maybe_async]
65+
async fn fetch_only_inner(
66+
&mut self,
67+
progress: &mut dyn crate::DynNestedProgress,
68+
should_interrupt: &std::sync::atomic::AtomicBool,
69+
) -> Result<(crate::Repository, crate::remote::fetch::Outcome), Error> {
6170
use crate::{bstr::ByteVec, remote, remote::fetch::RefLogMessage};
6271

6372
let repo = self
@@ -134,7 +143,7 @@ impl PrepareFetch {
134143
message: reflog_message.clone(),
135144
})
136145
.with_shallow(self.shallow.clone())
137-
.receive(progress, should_interrupt)
146+
.receive(DynNestedProgressToNestedProgress(progress), should_interrupt)
138147
.await?;
139148

140149
util::append_config_to_repo_config(repo, config);

gix/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub use gix_features as features;
8787
use gix_features::threading::OwnShared;
8888
pub use gix_features::{
8989
parallel,
90-
progress::{Count, NestedProgress, Progress},
90+
progress::{Count, DynNestedProgress, NestedProgress, Progress},
9191
threading,
9292
};
9393
pub use gix_fs as fs;

0 commit comments

Comments
 (0)