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
2 changes: 1 addition & 1 deletion src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
16 changes: 8 additions & 8 deletions src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub struct Command<'w, 'pl> {
args: Vec<OsString>,
env: Vec<(OsString, OsString)>,
process_lines: Option<&'pl mut dyn FnMut(&str, &mut ProcessLinesActions)>,
cd: Option<PathBuf>,
current_directory: Option<PathBuf>,
timeout: Option<Duration>,
no_output_timeout: Option<Duration>,
log_command: bool,
Expand All @@ -226,7 +226,7 @@ impl fmt::Debug for Command<'_, '_> {
.field("args", &self.args)
.field("env", &self.env.iter().map(|(k, _)| k).collect::<Vec<_>>())
.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)
Expand Down Expand Up @@ -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,
Expand All @@ -306,8 +306,8 @@ impl<'w> Command<'w, '_> {
}

/// Change the directory where the command will be executed in.
pub fn cd<P: AsRef<Path>>(mut self, path: P) -> Self {
self.cd = Some(path.as_ref().to_path_buf());
pub fn current_directory<P: AsRef<Path>>(mut self, path: P) -> Self {
self.current_directory = Some(path.as_ref().to_path_buf());
self
}

Expand Down Expand Up @@ -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("."),
};
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/crates/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl GitRepo {
pub(super) fn git_commit(&self, workspace: &Workspace) -> Option<String> {
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 {
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions src/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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))]
Expand Down Expand Up @@ -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() {
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/crates_git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -99,25 +99,25 @@ 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"])
.args(&["-c", "user.name=test"])
.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(),
Expand Down
Loading