Skip to content

Commit

Permalink
smoke_test: Create initial git commit before running `cargo package/p…
Browse files Browse the repository at this point in the history
…ublish`

This is a workaround for a cargo bug (rust-lang/cargo#14354).
  • Loading branch information
Turbo87 committed Sep 6, 2024
1 parent 8473891 commit 61ad91a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
25 changes: 25 additions & 0 deletions crates/crates_io_smoke_test/src/git.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use crate::exit_status_ext::ExitStatusExt;
use std::path::Path;
use tokio::process::Command;

#[allow(unstable_name_collisions)]
pub async fn add_all(project_path: &Path) -> anyhow::Result<()> {
Command::new("git")
.args(["add", "--all"])
.current_dir(project_path)
.status()
.await?
.exit_ok()
.map_err(Into::into)
}

#[allow(unstable_name_collisions)]
pub async fn commit(project_path: &Path, message: &str) -> anyhow::Result<()> {
Command::new("git")
.args(["commit", "--message", message])
.current_dir(project_path)
.status()
.await?
.exit_ok()
.map_err(Into::into)
}
10 changes: 10 additions & 0 deletions crates/crates_io_smoke_test/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod api;
mod cargo;
mod exit_status_ext;
mod git;

#[macro_use]
extern crate tracing;
Expand Down Expand Up @@ -224,5 +225,14 @@ description = "test crate"
.context("Failed to write `README.md` file content")?;
}

info!("Creating initial git commit…");
git::add_all(&project_path)
.await
.context("Failed to add initial changes to git")?;

git::commit(&project_path, "initial commit")
.await
.context("Failed to commit initial changes")?;

Ok(project_path)
}

0 comments on commit 61ad91a

Please sign in to comment.