Skip to content

Commit

Permalink
fix(cargo-package): add more traces (#14960)
Browse files Browse the repository at this point in the history
### What does this PR try to resolve?

This helps debug <#14955>.

### How should we test and review this PR?

While `check_repo_state` is the culprit, let's add some traces for
future.

### Additional information
  • Loading branch information
epage authored Dec 19, 2024
2 parents 58b2d60 + 6d6b608 commit 1296566
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ struct GitVcsInfo {
}

// Builds a tarball and places it in the output directory.
#[tracing::instrument(skip_all)]
fn create_package(
ws: &Workspace<'_>,
pkg: &Package,
Expand Down Expand Up @@ -372,6 +373,7 @@ fn local_deps<T>(packages: impl Iterator<Item = (Package, T)>) -> LocalDependenc
}

/// Performs pre-archiving checks and builds a list of files to archive.
#[tracing::instrument(skip_all)]
fn prepare_archive(
ws: &Workspace<'_>,
pkg: &Package,
Expand Down Expand Up @@ -400,6 +402,7 @@ fn prepare_archive(
}

/// Builds list of files to archive.
#[tracing::instrument(skip_all)]
fn build_ar_list(
ws: &Workspace<'_>,
pkg: &Package,
Expand Down Expand Up @@ -730,6 +733,7 @@ fn check_metadata(pkg: &Package, gctx: &GlobalContext) -> CargoResult<()> {
/// has not been passed, then `bail!` with an informative message. Otherwise
/// return the sha1 hash of the current *HEAD* commit, or `None` if no repo is
/// found.
#[tracing::instrument(skip_all)]
fn check_repo_state(
p: &Package,
src_files: &[PathBuf],
Expand Down Expand Up @@ -780,7 +784,7 @@ fn check_repo_state(
return Ok(None);

fn git(
p: &Package,
pkg: &Package,
src_files: &[PathBuf],
repo: &git2::Repository,
opts: &PackageOpts<'_>,
Expand All @@ -803,7 +807,7 @@ fn check_repo_state(
.iter()
.filter(|src_file| dirty_files.iter().any(|path| src_file.starts_with(path)))
.map(|path| {
path.strip_prefix(p.root())
path.strip_prefix(pkg.root())
.unwrap_or(path)
.display()
.to_string()
Expand Down
1 change: 1 addition & 0 deletions src/cargo/sources/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ impl<'gctx> PathSource<'gctx> {
/// are relevant for building this package, but it also contains logic to
/// use other methods like `.gitignore`, `package.include`, or
/// `package.exclude` to filter the list of files.
#[tracing::instrument(skip_all)]
pub fn list_files(&self, pkg: &Package) -> CargoResult<Vec<PathBuf>> {
list_files(pkg, self.gctx)
}
Expand Down

0 comments on commit 1296566

Please sign in to comment.