mirror of
https://github.com/openai/codex.git
synced 2026-11-12 21:20:34 +00:00
fix(git-utils): reuse runner for merge-base
This commit is contained in:
@@ -61,6 +61,8 @@ impl GitCommand {
|
||||
|
||||
impl GitRunner {
|
||||
pub(crate) fn for_cwd(cwd: &Path) -> Result<Self, GitReadError> {
|
||||
#[cfg(test)]
|
||||
GIT_RUNNER_CONSTRUCTION_COUNT.with(|count| count.set(count.get() + 1));
|
||||
let authority = repository_authority_for_cwd(cwd)?;
|
||||
let search_path = std::env::var_os("PATH").ok_or(GitReadError::NoTrustedGit)?;
|
||||
Self::from_search_path(authority, &search_path)
|
||||
@@ -125,6 +127,21 @@ impl GitRunner {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
thread_local! {
|
||||
static GIT_RUNNER_CONSTRUCTION_COUNT: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn reset_git_runner_construction_count() {
|
||||
GIT_RUNNER_CONSTRUCTION_COUNT.with(|count| count.set(0));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn git_runner_construction_count() -> usize {
|
||||
GIT_RUNNER_CONSTRUCTION_COUNT.with(std::cell::Cell::get)
|
||||
}
|
||||
|
||||
pub(crate) fn repository_authority_for_cwd(
|
||||
cwd: &Path,
|
||||
) -> Result<RepositoryAuthority, GitReadError> {
|
||||
|
||||
Reference in New Issue
Block a user