mirror of
https://github.com/openai/codex.git
synced 2026-05-16 01:02:48 +00:00
# Conflicts: # codex-rs/codex-mcp/src/mcp/mod_tests.rs # codex-rs/core/src/config/config_tests.rs # codex-rs/core/src/config/mod.rs # codex-rs/core/src/config_loader/mod.rs # codex-rs/core/src/guardian/review_session.rs # codex-rs/core/src/original_image_detail_tests.rs # codex-rs/core/src/realtime_context_tests.rs # codex-rs/core/src/tools/spec_tests.rs # codex-rs/exec-server/src/environment.rs # codex-rs/exec-server/src/file_system.rs # codex-rs/exec-server/src/lib.rs # codex-rs/models-manager/src/model_info_tests.rs # codex-rs/tui_app_server/src/onboarding/onboarding_screen.rs # codex-rs/tui_app_server/src/onboarding/trust_directory.rs
codex-git-utils
Helpers for interacting with git, including patch application and worktree snapshot utilities.
use std::path::Path;
use codex_git_utils::{
apply_git_patch, create_ghost_commit, restore_ghost_commit, ApplyGitRequest,
CreateGhostCommitOptions,
};
let repo = Path::new("/path/to/repo");
// Apply a patch (omitted here) to the repository.
let request = ApplyGitRequest {
cwd: repo.to_path_buf(),
diff: String::from("...diff contents..."),
revert: false,
preflight: false,
};
let result = apply_git_patch(&request)?;
// Capture the current working tree as an unreferenced commit.
let ghost = create_ghost_commit(&CreateGhostCommitOptions::new(repo))?;
// Later, undo back to that state.
restore_ghost_commit(repo, &ghost)?;
Pass a custom message with .message("…") or force-include ignored files with
.force_include(["ignored.log".into()]).