Skip to content

Commit fbf681f

Browse files
committed
fix: span behaviour / mirror flag
1 parent 0db5985 commit fbf681f

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

rust/patchable/src/main.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{fs::File, io::Write, path::PathBuf};
99

1010
use git2::{Oid, Repository};
1111
use serde::{Deserialize, Serialize};
12-
use snafu::{ensure, OptionExt, ResultExt as _, Snafu};
12+
use snafu::{OptionExt, ResultExt as _, Snafu};
1313
use tracing_indicatif::IndicatifLayer;
1414
use tracing_subscriber::{layer::SubscriberExt as _, util::SubscriberInitExt as _};
1515

@@ -419,7 +419,7 @@ fn main() -> Result<()> {
419419
pv,
420420
upstream,
421421
base,
422-
mirrored,
422+
mirror,
423423
} => {
424424
let ctx = ProductVersionContext {
425425
pv,
@@ -440,11 +440,9 @@ fn main() -> Result<()> {
440440
let base_commit = repo::resolve_and_fetch_commitish(&product_repo, &base, &upstream).context(FetchBaseCommitSnafu)?;
441441
let mut upstream_mirror = None;
442442

443-
if mirrored {
443+
if mirror {
444444
// Parse e.g. "https://github.com/apache/druid.git" into "druid"
445-
let repo_name = upstream.split('/').last().map(|repo| repo.trim_end_matches(".git")).context(ParseUpstreamUrlSnafu { url: &upstream })?;
446-
447-
ensure!(!repo_name.is_empty(), ParseUpstreamUrlSnafu { url: &upstream });
445+
let repo_name = upstream.split('/').last().map(|repo| repo.trim_end_matches(".git")).filter(|name| !name.is_empty()).context(ParseUpstreamUrlSnafu { url: &upstream })?;
448446

449447
let mirror_url = format!("https://github.com/stackabletech/{repo_name}.git");
450448
tracing::info!(mirror_url, "using mirror repository");
@@ -457,16 +455,18 @@ fn main() -> Result<()> {
457455
// Push the base commit to the mirror
458456
tracing::info!(commit = %base_commit, base = base, url = mirror_url, "pushing commit to mirror");
459457
let mut callbacks = git2::RemoteCallbacks::new();
460-
callbacks.credentials(|_url, username_from_url, _allowed_types| {
458+
callbacks.credentials(|url, username_from_url, _allowed_types| {
461459
git2::Cred::credential_helper(
462460
&git2::Config::open_default().unwrap(), // Use default git config
463-
_url,
461+
url,
464462
username_from_url,
465463
)
466464
});
467465

468466
// Add progress tracking for push operation
469467
let (span_push, mut quant_push) = utils::setup_progress_tracking(tracing::info_span!("pushing"));
468+
let _ = span_push.enter();
469+
470470
callbacks.push_transfer_progress(move |current, total, _| {
471471
if total > 0 {
472472
quant_push.update_span_progress(

rust/patchable/src/repo.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ pub fn resolve_and_fetch_commitish(
152152
let (span_recv, mut quant_recv) = setup_progress_tracking(tracing::info_span!("receiving"));
153153
let (span_index, mut quant_index) = setup_progress_tracking(tracing::info_span!("indexing"));
154154

155+
let _ = span_recv.enter();
156+
let _ = span_index.enter();
157+
155158
let mut callbacks = RemoteCallbacks::new();
156159
callbacks.transfer_progress(move |progress| {
157160
quant_recv.update_span_progress(

rust/patchable/src/utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ pub fn setup_progress_tracking(span: tracing::Span) -> (tracing::Span, Quantizer
9494
"{span_child_prefix}{spinner} {span_name}{{{span_fields}}} {wide_msg} {bar:40} {percent:>3}%",
9595
)
9696
.expect("hard-coded template should be valid"));
97-
let _ = span.enter();
9897
let quantizer = Quantizer::percent();
9998
(span, quantizer)
10099
}

0 commit comments

Comments
 (0)