mirror of
https://github.com/openai/codex.git
synced 2026-06-02 19:31:59 +00:00
Avoid git probes outside repositories
The metadata rewrite added git metadata collection to live thread creation and kept SessionMeta git collection in the rollout recorder. Those paths can also run with temporary working directories that are not git repositories, especially in app-server integration tests. collect_git_info may spawn git and wait for its timeout before discovering that a directory is not a repository. On slower CI platforms that extra subprocess work made unrelated app-server startup tests miss their existing deadlines. Guard the call sites with get_git_repo_root first. Non-repository directories now skip git probing and record no git metadata, while real repository working directories still collect the same commit, branch, and remote information as before. This is a focused performance/behavior fix rather than a test timeout increase.
This commit is contained in:
@@ -48,6 +48,7 @@ use crate::default_client::originator;
|
||||
use crate::state_db;
|
||||
use crate::state_db::StateDbHandle;
|
||||
use codex_git_utils::collect_git_info;
|
||||
use codex_git_utils::get_git_repo_root;
|
||||
use codex_protocol::protocol::GitInfo as ProtocolGitInfo;
|
||||
use codex_protocol::protocol::InitialHistory;
|
||||
use codex_protocol::protocol::ResumedHistory;
|
||||
@@ -1580,11 +1581,15 @@ async fn write_session_meta(
|
||||
session_meta: SessionMeta,
|
||||
cwd: &Path,
|
||||
) -> std::io::Result<()> {
|
||||
let git_info = collect_git_info(cwd).await.map(|info| ProtocolGitInfo {
|
||||
commit_hash: info.commit_hash,
|
||||
branch: info.branch,
|
||||
repository_url: info.repository_url,
|
||||
});
|
||||
let git_info = if get_git_repo_root(cwd).is_some() {
|
||||
collect_git_info(cwd).await.map(|info| ProtocolGitInfo {
|
||||
commit_hash: info.commit_hash,
|
||||
branch: info.branch,
|
||||
repository_url: info.repository_url,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let session_meta_line = SessionMetaLine {
|
||||
meta: session_meta,
|
||||
git: git_info,
|
||||
|
||||
@@ -5,6 +5,7 @@ use chrono::DateTime;
|
||||
use chrono::NaiveDateTime;
|
||||
use chrono::Utc;
|
||||
use codex_git_utils::collect_git_info;
|
||||
use codex_git_utils::get_git_repo_root;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
use codex_protocol::protocol::GitInfo;
|
||||
@@ -51,11 +52,15 @@ impl ThreadMetadataSync {
|
||||
pub(crate) async fn for_create(params: &CreateThreadParams) -> Self {
|
||||
let created_at = Utc::now();
|
||||
let cwd = params.metadata.cwd.clone().unwrap_or_default();
|
||||
let git_info = collect_git_info(cwd.as_path()).await.map(|info| GitInfo {
|
||||
commit_hash: info.commit_hash,
|
||||
branch: info.branch,
|
||||
repository_url: info.repository_url,
|
||||
});
|
||||
let git_info = if get_git_repo_root(cwd.as_path()).is_some() {
|
||||
collect_git_info(cwd.as_path()).await.map(|info| GitInfo {
|
||||
commit_hash: info.commit_hash,
|
||||
branch: info.branch,
|
||||
repository_url: info.repository_url,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let dynamic_tools =
|
||||
(!params.dynamic_tools.is_empty()).then(|| params.dynamic_tools.clone());
|
||||
let update = ThreadMetadataPatch {
|
||||
|
||||
Reference in New Issue
Block a user