mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 00:21:05 -05:00
feat(publish): check for uncommitted files in deno publish --dry-run
(#22981)
Closes #22936
This commit is contained in:
parent
85236576b2
commit
2d59372e7a
2 changed files with 40 additions and 9 deletions
|
@ -988,6 +988,15 @@ pub async fn publish(
|
|||
bail!("No packages to publish");
|
||||
}
|
||||
|
||||
if std::env::var("DENO_TESTING_DISABLE_GIT_CHECK")
|
||||
.ok()
|
||||
.is_none()
|
||||
&& !publish_flags.allow_dirty
|
||||
&& check_if_git_repo_dirty(cli_options.initial_cwd()).await
|
||||
{
|
||||
bail!("Aborting due to uncommitted changes. Check in source code or run with --allow-dirty");
|
||||
}
|
||||
|
||||
if publish_flags.dry_run {
|
||||
for (_, package) in prepared_data.package_by_name {
|
||||
log::info!(
|
||||
|
@ -1003,15 +1012,6 @@ pub async fn publish(
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
if std::env::var("DENO_TESTING_DISABLE_GIT_CHECK")
|
||||
.ok()
|
||||
.is_none()
|
||||
&& !publish_flags.allow_dirty
|
||||
&& check_if_git_repo_dirty(cli_options.initial_cwd()).await
|
||||
{
|
||||
bail!("Aborting due to uncommitted changes. Check in source code or run with --allow-dirty");
|
||||
}
|
||||
|
||||
perform_publish(
|
||||
cli_factory.http_client(),
|
||||
prepared_data.publish_order_graph,
|
||||
|
|
|
@ -708,3 +708,34 @@ fn allow_dirty_not_in_repo() {
|
|||
let output = output.combined_output();
|
||||
assert_contains!(output, "Successfully published");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_dirty_dry_run() {
|
||||
let context = publish_context_builder_with_git_checks().build();
|
||||
let temp_dir = context.temp_dir().path();
|
||||
temp_dir.join("deno.json").write_json(&json!({
|
||||
"name": "@foo/bar",
|
||||
"version": "1.0.0",
|
||||
"exports": "./main.ts",
|
||||
}));
|
||||
|
||||
temp_dir.join("main.ts").write("");
|
||||
|
||||
let cmd = Command::new("git")
|
||||
.arg("init")
|
||||
.arg(temp_dir.as_path())
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(cmd.status.success());
|
||||
|
||||
let output = context
|
||||
.new_command()
|
||||
.arg("publish")
|
||||
.arg("--dry-run")
|
||||
.arg("--token")
|
||||
.arg("sadfasdf")
|
||||
.run();
|
||||
output.assert_exit_code(1);
|
||||
let output = output.combined_output();
|
||||
assert_contains!(output, "Aborting due to uncommitted changes. Check in source code or run with --allow-dirty");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue