Skip to content

Commit 61ad91a

Browse files
committed
smoke_test: Create initial git commit before running cargo package/publish
This is a workaround for a cargo bug (rust-lang/cargo#14354).
1 parent 8473891 commit 61ad91a

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use crate::exit_status_ext::ExitStatusExt;
2+
use std::path::Path;
3+
use tokio::process::Command;
4+
5+
#[allow(unstable_name_collisions)]
6+
pub async fn add_all(project_path: &Path) -> anyhow::Result<()> {
7+
Command::new("git")
8+
.args(["add", "--all"])
9+
.current_dir(project_path)
10+
.status()
11+
.await?
12+
.exit_ok()
13+
.map_err(Into::into)
14+
}
15+
16+
#[allow(unstable_name_collisions)]
17+
pub async fn commit(project_path: &Path, message: &str) -> anyhow::Result<()> {
18+
Command::new("git")
19+
.args(["commit", "--message", message])
20+
.current_dir(project_path)
21+
.status()
22+
.await?
23+
.exit_ok()
24+
.map_err(Into::into)
25+
}

crates/crates_io_smoke_test/src/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
mod api;
22
mod cargo;
33
mod exit_status_ext;
4+
mod git;
45

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

228+
info!("Creating initial git commit…");
229+
git::add_all(&project_path)
230+
.await
231+
.context("Failed to add initial changes to git")?;
232+
233+
git::commit(&project_path, "initial commit")
234+
.await
235+
.context("Failed to commit initial changes")?;
236+
227237
Ok(project_path)
228238
}

0 commit comments

Comments
 (0)