dep: Bump gix from v0.52.0 => v0.53.1 (#1354)

* dep: Bump gix from v0.52.0 => v0.53.1

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix `gix` compilation: Enable `gix/max-performance-safe`

without this feature, `ThreadSafeRepository` does not implement `Sync`,
causes the `binstalk-registry` compilation to fail.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Enable `gix/comfort` for progress tracing

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fixed gix progress tracking: Enable `gix/progress-tree`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Rm feature `gix/{comfort, progress-tree}`

Since they do not enable progress support and merely adds bloat.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix gix progress logging: Allow logging from simple-git

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Re-enable feature `gix/comfort` for more readable logging

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-09-14 23:31:00 +10:00 committed by GitHub
parent f26ab41961
commit f31db762b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 164 additions and 231 deletions

View file

@ -202,6 +202,7 @@ pub fn logging(log_level: LevelFilter, json_output: bool) {
"binstalk_registry",
"cargo_binstall",
"cargo_toml_workspace",
"simple_git",
]);
// Forward log to tracing

View file

@ -13,11 +13,20 @@ license = "Apache-2.0 OR MIT"
[dependencies]
compact_str = "0.7.0"
derive_destructure2 = "0.1"
gix = { version = "0.52.0", features = ["blocking-http-transport-reqwest"] }
thiserror = "1.0.40"
tokio = { version = "1.30.0", features = ["rt", "time"], default-features = false }
tracing = "0.1.37"
[dependencies.gix]
version = "0.53.1"
default-features = false
features = [
"comfort",
"blocking-http-transport-reqwest",
"max-performance-safe",
"worktree-mutation",
]
[features]
rustls = [
"gix/blocking-http-transport-reqwest-rust-tls",

View file

@ -8,7 +8,8 @@ use std::{
use compact_str::{format_compact, CompactString};
use gix::progress::{
prodash::messages::MessageLevel, Id, Progress, Step, StepShared, Unit, UNKNOWN,
prodash::messages::MessageLevel, Count, Id, NestedProgress, Progress, Step, StepShared, Unit,
UNKNOWN,
};
use tokio::time;
use tracing::{error, info};
@ -18,7 +19,7 @@ pub(super) struct TracingProgress {
id: Id,
max: Option<usize>,
unit: Option<Unit>,
step: usize,
step: StepShared,
trigger: Arc<AtomicBool>,
}
@ -46,38 +47,13 @@ impl TracingProgress {
name: CompactString::new(name),
id: UNKNOWN,
max: None,
step: 0,
step: Default::default(),
unit: None,
trigger,
}
}
}
impl Progress for TracingProgress {
type SubProgress = TracingProgress;
fn add_child(&mut self, name: impl Into<String>) -> Self::SubProgress {
self.add_child_with_id(name, UNKNOWN)
}
fn add_child_with_id(&mut self, name: impl Into<String>, id: Id) -> Self::SubProgress {
Self {
name: format_compact!("{}{}{}", self.name, SEP, Into::<String>::into(name)),
id,
step: 0,
max: None,
unit: None,
trigger: Arc::clone(&self.trigger),
}
}
fn init(&mut self, max: Option<usize>, unit: Option<Unit>) {
self.max = max;
self.unit = unit;
}
fn set(&mut self, step: usize) {
self.step = step;
fn log_progress(&self, step: Step) {
if self.trigger.swap(false, Ordering::Relaxed) {
match (self.max, &self.unit) {
(max, Some(unit)) => {
@ -88,6 +64,36 @@ impl Progress for TracingProgress {
}
}
}
}
impl Count for TracingProgress {
fn set(&self, step: Step) {
self.step.store(step, Ordering::Relaxed);
self.log_progress(step);
}
fn step(&self) -> Step {
self.step.load(Ordering::Relaxed)
}
fn inc_by(&self, step_to_inc: Step) {
self.log_progress(
self.step
.fetch_add(step_to_inc, Ordering::Relaxed)
.wrapping_add(step_to_inc),
);
}
fn counter(&self) -> StepShared {
Arc::clone(&self.step)
}
}
impl Progress for TracingProgress {
fn init(&mut self, max: Option<Step>, unit: Option<Unit>) {
self.max = max;
self.unit = unit;
}
fn unit(&self) -> Option<Unit> {
self.unit.clone()
@ -103,21 +109,12 @@ impl Progress for TracingProgress {
prev
}
fn step(&self) -> usize {
self.step
}
fn inc_by(&mut self, step: usize) {
self.set(self.step + step)
}
fn set_name(&mut self, name: impl Into<String>) {
let name = name.into();
fn set_name(&mut self, name: String) {
self.name = self
.name
.split("::")
.next()
.map(|parent| format_compact!("{}{}{}", parent.to_owned(), SEP, name))
.map(|parent| format_compact!("{parent}{SEP}{name}"))
.unwrap_or_else(|| name.into());
}
@ -129,16 +126,31 @@ impl Progress for TracingProgress {
self.id
}
fn message(&self, level: MessageLevel, message: impl Into<String>) {
let message: String = message.into();
fn message(&self, level: MessageLevel, message: String) {
let name = &self.name;
match level {
MessageLevel::Info => info!("{} → {}", self.name, message),
MessageLevel::Failure => error!("𐄂{} → {}", self.name, message),
MessageLevel::Success => info!("✓{} → {}", self.name, message),
MessageLevel::Info => info!("{name} → {message}"),
MessageLevel::Failure => error!("𐄂{name} → {message}"),
MessageLevel::Success => info!("✓{name} → {message}"),
}
}
}
fn counter(&self) -> Option<StepShared> {
None
impl NestedProgress for TracingProgress {
type SubProgress = TracingProgress;
fn add_child(&mut self, name: impl Into<String>) -> Self::SubProgress {
self.add_child_with_id(name, UNKNOWN)
}
fn add_child_with_id(&mut self, name: impl Into<String>, id: Id) -> Self::SubProgress {
Self {
name: format_compact!("{}{}{}", self.name, SEP, Into::<String>::into(name)),
id,
step: Arc::default(),
max: None,
unit: None,
trigger: Arc::clone(&self.trigger),
}
}
}