mirror of
https://github.com/openai/codex.git
synced 2026-05-25 13:34:51 +00:00
We are removing feature-gated shared crates from the `codex-rs` workspace. `codex-common` grouped several unrelated utilities behind `[features]`, which made dependency boundaries harder to reason about and worked against the ongoing effort to eliminate feature flags from workspace crates. Splitting these utilities into dedicated crates under `utils/` aligns this area with existing workspace structure and keeps each dependency explicit at the crate boundary. ## What changed - Removed `codex-rs/common` (`codex-common`) from workspace members and workspace dependencies. - Added six new utility crates under `codex-rs/utils/`: - `codex-utils-cli` - `codex-utils-elapsed` - `codex-utils-sandbox-summary` - `codex-utils-approval-presets` - `codex-utils-oss` - `codex-utils-fuzzy-match` - Migrated the corresponding modules out of `codex-common` into these crates (with tests), and added matching `BUILD.bazel` targets. - Updated direct consumers to use the new crates instead of `codex-common`: - `codex-rs/cli` - `codex-rs/tui` - `codex-rs/exec` - `codex-rs/app-server` - `codex-rs/mcp-server` - `codex-rs/chatgpt` - `codex-rs/cloud-tasks` - Updated workspace lockfile entries to reflect the new dependency graph and removal of `codex-common`.
63 lines
1.6 KiB
Rust
63 lines
1.6 KiB
Rust
use std::collections::HashMap;
|
|
|
|
pub fn format_env_display(env: Option<&HashMap<String, String>>, env_vars: &[String]) -> String {
|
|
let mut parts: Vec<String> = Vec::new();
|
|
|
|
if let Some(map) = env {
|
|
let mut pairs: Vec<_> = map.iter().collect();
|
|
pairs.sort_by(|(a, _), (b, _)| a.cmp(b));
|
|
parts.extend(pairs.into_iter().map(|(key, _)| format!("{key}=*****")));
|
|
}
|
|
|
|
if !env_vars.is_empty() {
|
|
parts.extend(env_vars.iter().map(|var| format!("{var}=*****")));
|
|
}
|
|
|
|
if parts.is_empty() {
|
|
"-".to_string()
|
|
} else {
|
|
parts.join(", ")
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn returns_dash_when_empty() {
|
|
assert_eq!(format_env_display(None, &[]), "-");
|
|
|
|
let empty_map = HashMap::new();
|
|
assert_eq!(format_env_display(Some(&empty_map), &[]), "-");
|
|
}
|
|
|
|
#[test]
|
|
fn formats_sorted_env_pairs() {
|
|
let mut env = HashMap::new();
|
|
env.insert("B".to_string(), "two".to_string());
|
|
env.insert("A".to_string(), "one".to_string());
|
|
|
|
assert_eq!(format_env_display(Some(&env), &[]), "A=*****, B=*****");
|
|
}
|
|
|
|
#[test]
|
|
fn formats_env_vars_with_dollar_prefix() {
|
|
let vars = vec!["TOKEN".to_string(), "PATH".to_string()];
|
|
|
|
assert_eq!(format_env_display(None, &vars), "TOKEN=*****, PATH=*****");
|
|
}
|
|
|
|
#[test]
|
|
fn combines_env_pairs_and_vars() {
|
|
let mut env = HashMap::new();
|
|
env.insert("HOME".to_string(), "/tmp".to_string());
|
|
let vars = vec!["TOKEN".to_string()];
|
|
|
|
assert_eq!(
|
|
format_env_display(Some(&env), &vars),
|
|
"HOME=*****, TOKEN=*****"
|
|
);
|
|
}
|
|
}
|