Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tracing logs around git dirty hashes listing #344

Merged
merged 5 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mighty-zoos-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@atlaspack/rust': minor
---

Add tracing logs for dirty files listing
15 changes: 15 additions & 0 deletions crates/atlaspack_vcs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ use std::{
hash::{Hash, Hasher},
path::{Path, PathBuf},
process::Command,
time::Instant,
};
use yarn_integration::{parse_yarn_lock, parse_yarn_state_file, YarnLock, YarnStateFile};

Expand All @@ -138,6 +139,7 @@ pub mod yarn_integration;
pub struct VCSState {
pub git_hash: String,
pub dirty_files: Vec<VCSFile>,
pub dirty_files_execution_time: u32,
pub yarn_states: Vec<YarnSnapshot>,
}

Expand All @@ -150,18 +152,30 @@ impl VCSState {
failure_mode: FailureMode,
) -> anyhow::Result<VCSState> {
tracing::info!("Reading VCS state");
let start_time = Instant::now();

let repo = Repository::open(path)?;
let head = repo.revparse_single("HEAD")?.peel_to_commit()?;
let git_hash = head.id().to_string();
tracing::info!("Found head commit");
let file_listing = vcs_list_dirty_files(path, exclude_patterns)?;
let files_listing_duration = start_time
.elapsed()
.as_millis()
.try_into()
.unwrap_or(u32::MAX);
tracing::info!(
"vcs_list_dirty_files executed in: {:?}",
files_listing_duration
);
tracing::info!("Listed dirty files");
let yarn_states = list_yarn_states(path, failure_mode)?;
tracing::info!("Listed yarn states");

Ok(VCSState {
git_hash,
dirty_files: file_listing,
dirty_files_execution_time: files_listing_duration,
yarn_states,
})
}
Expand Down Expand Up @@ -358,6 +372,7 @@ pub fn vcs_list_yarn_lock_files(dir: &Path) -> Result<Vec<String>, anyhow::Error
Ok(results)
}

#[tracing::instrument(level = "info", skip_all)]
pub fn vcs_list_dirty_files(
dir: &Path,
exclude_patterns: &[String],
Expand Down
1 change: 1 addition & 0 deletions packages/core/rust/index.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ export interface YarnState {

export interface VCSState {
gitHash: string;
// Files that have been modified since the last commit
dirtyFiles: VCSFile[];
yarnStates: YarnState[];
}
Expand Down