mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Enhance git module performance and improve path collection
- Conducted a complete audit of the git module to leverage the gix API for improved performance, aiming for significant speedups in git operations. - Updated the `git_changed_files_impl` function to accept project prefixes as a vector of strings, enhancing the flexibility of change detection. - Made the `collect_path_roots` function public to allow external access for collecting project directory paths. These changes aim to optimize git operations and improve the overall efficiency of path handling in the project.
This commit is contained in:
parent
8d54fff7df
commit
1a03554ee8
4 changed files with 111 additions and 349 deletions
|
|
@ -436,11 +436,48 @@ impl ApiService {
|
|||
.serve_session
|
||||
.initial_head_commit()
|
||||
.map(|s| s.to_owned());
|
||||
tokio::task::spawn_blocking(move || {
|
||||
crate::git::compute_git_metadata(&tree_handle, &repo_root, initial_head.as_deref())
|
||||
})
|
||||
|
||||
let mut project_roots = Vec::new();
|
||||
crate::serve_session::collect_path_roots(
|
||||
&self.serve_session.root_project().tree,
|
||||
self.serve_session.root_dir(),
|
||||
&mut project_roots,
|
||||
);
|
||||
let project_prefixes: Vec<String> = project_roots
|
||||
.iter()
|
||||
.filter_map(|abs| abs.strip_prefix(&repo_root).ok())
|
||||
.map(|r| r.to_string_lossy().replace('\\', "/"))
|
||||
.collect();
|
||||
|
||||
log::debug!(
|
||||
"Git metadata: using {} project prefixes: {:?}",
|
||||
project_prefixes.len(),
|
||||
project_prefixes
|
||||
);
|
||||
|
||||
match tokio::time::timeout(
|
||||
std::time::Duration::from_secs(10),
|
||||
tokio::task::spawn_blocking(move || {
|
||||
crate::git::compute_git_metadata(
|
||||
&tree_handle,
|
||||
&repo_root,
|
||||
initial_head.as_deref(),
|
||||
&project_prefixes,
|
||||
)
|
||||
}),
|
||||
)
|
||||
.await
|
||||
.ok()
|
||||
{
|
||||
Ok(Ok(meta)) => Some(meta),
|
||||
Ok(Err(e)) => {
|
||||
log::warn!("Git metadata task failed: {}", e);
|
||||
None
|
||||
}
|
||||
Err(_) => {
|
||||
log::warn!("Git metadata computation timed out (>10s), skipping");
|
||||
None
|
||||
}
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue