Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/apps/cli/src/dispatch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ mod worker;
mod workspace;

use std::path::{Path, PathBuf};
use std::process::Command;

use anyhow::{anyhow, bail, Context, Result};
use bitfun_core::infrastructure::ai::AIClientFactory;
use bitfun_core::service::config::{AuthConfig, GlobalConfig};
use bitfun_core::service::git::trust;
use bitfun_services_core::process_manager;
use serde::de::DeserializeOwned;

use protocol::{
Expand Down Expand Up @@ -853,7 +853,7 @@ fn classify_repository_probe(result: Result<GitProbeOutput, GitProbeOutput>) ->
/// below matches Git's English prose, and a localized host would otherwise make
/// an ownership rejection unrecognizable.
fn git_probe(workspace: &Path, args: &[&str]) -> Result<GitProbeOutput, GitProbeOutput> {
let output = Command::new("git")
let output = process_manager::create_command("git")
.env("LC_ALL", "C")
.arg("-C")
.arg(workspace)
Expand Down
3 changes: 2 additions & 1 deletion src/apps/cli/src/dispatch/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::time::{Duration, Instant};
use anyhow::{bail, Context, Result};
use base64::Engine as _;
use bitfun_services_core::dispatch_workspace::sha256_file;
use bitfun_services_core::process_manager;
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};

Expand Down Expand Up @@ -1573,7 +1574,7 @@ fn commit_exists(repo: &Path, commit: &str) -> Result<bool> {
}

fn git_command(dir: &Path) -> Command {
let mut command = Command::new("git");
let mut command = process_manager::create_command("git");
command
.current_dir(dir)
// A detached dispatch worker has nobody to answer a credential or
Expand Down
6 changes: 3 additions & 3 deletions src/apps/cli/src/modes/chat/external_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ fn editor_process(
command: &EditorCommand,
path: &std::path::Path,
) -> Result<Command, EditorRunError> {
let mut process = Command::new(&command.program);
let mut process = bitfun_core::util::process_manager::create_command(&command.program);
process.args(&command.args).arg(path);
Ok(process)
}
Expand All @@ -235,15 +235,15 @@ fn editor_process(
}
values.push(quote_windows_batch_value(path.as_os_str())?);
let command_line = values.join(" ");
let mut process = Command::new("cmd.exe");
let mut process = bitfun_core::util::process_manager::create_command("cmd.exe");
process.args(["/d", "/v:off", "/s", "/c"]);
// cmd.exe requires an extra outer quote pair when the command itself
// begins with a quoted executable path. raw_arg is intentional here:
// Rust's argv quoting does not escape cmd metacharacters.
process.raw_arg(format!("\"{command_line}\""));
Ok(process)
} else {
let mut process = Command::new(&command.program);
let mut process = bitfun_core::util::process_manager::create_command(&command.program);
process.args(&command.args).arg(path);
Ok(process)
}
Expand Down
4 changes: 2 additions & 2 deletions src/apps/cli/src/modes/exec/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ pub(super) async fn run_verifier(
retries_used: u32,
) -> VerifyOutcome {
let mut process = if cfg!(windows) {
let mut process = tokio::process::Command::new("cmd");
let mut process = bitfun_services_core::process_manager::create_tokio_command("cmd");
process.arg("/C").arg(command);
process
} else {
let mut process = tokio::process::Command::new("sh");
let mut process = bitfun_services_core::process_manager::create_tokio_command("sh");
process.arg("-c").arg(command);
process
};
Expand Down
3 changes: 1 addition & 2 deletions src/apps/desktop/src/api/dispatch_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::time::Duration;
use anyhow::{anyhow, Context};
use serde_json::Value;
use tokio::io::AsyncWriteExt;
use tokio::process::Command;

const TARGET_COMMAND_TIMEOUT: Duration = Duration::from_secs(110);
const MAX_TARGET_RESPONSE_BYTES: usize = 4 * 1024 * 1024;
Expand Down Expand Up @@ -53,7 +52,7 @@ fn target_cli_verb(command: &str) -> Option<&'static str> {

async fn invoke_cli(executable: &Path, verb: &str, args: Value) -> anyhow::Result<Value> {
let request = serde_json::to_vec(&args).context("serialize target dispatch request")?;
let mut child = Command::new(executable)
let mut child = bitfun_core::util::process_manager::create_tokio_command(executable)
.arg("dispatch")
.arg(verb)
.stdin(std::process::Stdio::piped())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::path::{Path, PathBuf};
#[cfg(test)]
use std::process::Command;

use bitfun_services_core::process_manager;
use tokio::task::spawn_blocking;

pub(crate) const DEFAULT_AUTO_INDEX_MIN_FILES: usize = 2_000;
Expand Down Expand Up @@ -99,7 +101,7 @@ fn git_ls_files_indexable_count(
policy: AutoIndexPolicy,
carried: usize,
) -> Result<usize, String> {
let output = Command::new("git")
let output = process_manager::create_command("git")
.arg("ls-files")
.args(selectors)
.arg("-z")
Expand Down Expand Up @@ -128,7 +130,7 @@ fn git_ls_files_indexable_count(
}

fn git_worktree_root(repo_root: &Path) -> Result<PathBuf, String> {
let output = Command::new("git")
let output = process_manager::create_command("git")
.args(["rev-parse", "--show-toplevel"])
.current_dir(repo_root)
.output()
Expand All @@ -146,7 +148,7 @@ fn git_worktree_root(repo_root: &Path) -> Result<PathBuf, String> {
}
let worktree_root = dunce::canonicalize(root)
.map_err(|error| format!("cannot canonicalize Git worktree root: {error}"))?;
let head = Command::new("git")
let head = process_manager::create_command("git")
.args(["rev-parse", "--verify", "HEAD^{commit}"])
.current_dir(&worktree_root)
.output()
Expand Down