diff --git a/src/build.rs b/src/build.rs index 05a8a3e..9c3bfbc 100644 --- a/src/build.rs +++ b/src/build.rs @@ -295,7 +295,7 @@ impl<'ws> Build<'ws> { .mount(&self.dir.target_dir(), container_dir, MountKind::ReadWrite), bin, ) - .cd(self.dir.source_dir()) + .current_directory(self.dir.source_dir()) .env("CARGO_TARGET_DIR", container_dir) } diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index f5f2cdb..86fd416 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -207,7 +207,7 @@ pub struct Command<'w, 'pl> { args: Vec, env: Vec<(OsString, OsString)>, process_lines: Option<&'pl mut dyn FnMut(&str, &mut ProcessLinesActions)>, - cd: Option, + current_directory: Option, timeout: Option, no_output_timeout: Option, log_command: bool, @@ -226,7 +226,7 @@ impl fmt::Debug for Command<'_, '_> { .field("args", &self.args) .field("env", &self.env.iter().map(|(k, _)| k).collect::>()) .field("has_process_lines", &self.process_lines.is_some()) - .field("cd", &self.cd) + .field("current_directory", &self.current_directory) .field("timeout", &self.timeout) .field("no_output_timeout", &self.no_output_timeout) .field("log_command", &self.log_command) @@ -279,7 +279,7 @@ impl<'w> Command<'w, '_> { args: Vec::new(), env: Vec::new(), process_lines: None, - cd: None, + current_directory: None, timeout, no_output_timeout, log_output: true, @@ -306,8 +306,8 @@ impl<'w> Command<'w, '_> { } /// Change the directory where the command will be executed in. - pub fn cd>(mut self, path: P) -> Self { - self.cd = Some(path.as_ref().to_path_buf()); + pub fn current_directory>(mut self, path: P) -> Self { + self.current_directory = Some(path.as_ref().to_path_buf()); self } @@ -436,7 +436,7 @@ impl<'w> Command<'w, '_> { cmd.push(arg.to_string_lossy().to_string()); } - let source_dir = match self.cd { + let source_dir = match self.current_directory { Some(path) => path, None => PathBuf::from("."), }; @@ -534,8 +534,8 @@ impl<'w> Command<'w, '_> { let cmdstr = format!("{cmd:?}"); - if let Some(ref cd) = self.cd { - cmd.current_dir(cd); + if let Some(ref current_directory) = self.current_directory { + cmd.current_dir(current_directory); } if self.log_command { diff --git a/src/crates/git.rs b/src/crates/git.rs index dd17ecc..9d99c37 100644 --- a/src/crates/git.rs +++ b/src/crates/git.rs @@ -18,7 +18,7 @@ impl GitRepo { pub(super) fn git_commit(&self, workspace: &Workspace) -> Option { let res = Command::new(workspace, "git") .args(&["rev-parse", "HEAD"]) - .cd(self.cached_path(workspace)) + .current_directory(self.cached_path(workspace)) .run_capture(); match res { @@ -97,7 +97,7 @@ impl CrateTrait for GitRepo { .args(&self.suppress_password_prompt_args(workspace)) .args(&["-c", "remote.origin.fetch=refs/heads/*:refs/heads/*"]) .args(&["fetch", "origin", "--force", "--prune"]) - .cd(&path) + .current_directory(&path) .process_lines(&mut detect_private_repositories) .run() .with_context(|| format!("failed to update {}", self.url)) diff --git a/src/prepare.rs b/src/prepare.rs index 96710eb..6d5bcae 100644 --- a/src/prepare.rs +++ b/src/prepare.rs @@ -70,7 +70,7 @@ impl<'a> Prepare<'a> { let res = Command::new(self.workspace, self.toolchain.cargo()) .args(&["metadata", "--manifest-path", "Cargo.toml", "--no-deps"]) - .cd(self.source_dir) + .current_directory(self.source_dir) .log_output(false) .run(); if res.is_err() { @@ -128,7 +128,7 @@ impl<'a> Prepare<'a> { .env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly"); } - run_command(cmd.cd(self.source_dir)) + run_command(cmd.current_directory(self.source_dir)) } #[cfg_attr(feature = "tracing", tracing::instrument(skip_all))] @@ -156,7 +156,7 @@ pub(crate) fn fetch_deps( ) -> anyhow::Result<()> { let mut cmd = Command::new(workspace, toolchain.cargo()) .args(&["fetch", "--manifest-path", "Cargo.toml"]) - .cd(source_dir); + .current_directory(source_dir); // Pass `-Zbuild-std` in case a build in the sandbox wants to use it; // build-std has to have the source for libstd's dependencies available. if !fetch_build_std_targets.is_empty() { diff --git a/tests/integration/crates_git.rs b/tests/integration/crates_git.rs index 5b1f91b..7821c0f 100644 --- a/tests/integration/crates_git.rs +++ b/tests/integration/crates_git.rs @@ -20,7 +20,7 @@ fn test_fetch() -> anyhow::Result<()> { .run(|build| { Ok(Command::new(&workspace, "git") .args(&["rev-parse", "HEAD"]) - .cd(build.host_source_dir()) + .current_directory(build.host_source_dir()) .run_capture()? .stdout_lines()[0] .to_string()) @@ -99,7 +99,7 @@ impl Repo { fn commit(&mut self, workspace: &Workspace) -> anyhow::Result<()> { Command::new(workspace, "git") .args(&["add", "."]) - .cd(self.source.path()) + .current_directory(self.source.path()) .run()?; Command::new(workspace, "git") .args(&["-c", "commit.gpgsign=false"]) @@ -107,17 +107,17 @@ impl Repo { .args(&["-c", "user.email=test@example.com"]) .args(&["commit", "-m", "auto commit"]) .args(&["--allow-empty"]) - .cd(self.source.path()) + .current_directory(self.source.path()) .run()?; Command::new(workspace, "git") .args(&["update-server-info"]) - .cd(self.source.path()) + .current_directory(self.source.path()) .run()?; self.last_commit_sha = Some( Command::new(workspace, "git") .args(&["rev-parse", "HEAD"]) - .cd(self.source.path()) + .current_directory(self.source.path()) .run_capture()? .stdout_lines()[0] .to_string(),