mirror of
https://github.com/denoland/deno
synced 2024-10-04 07:09:20 +00:00
feat(publish): check for uncommitted files in deno publish --dry-run
(#22981)
Closes #22936
This commit is contained in:
parent
85236576b2
commit
2d59372e7a
|
@ -988,6 +988,15 @@ pub async fn publish(
|
||||||
bail!("No packages to 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 {
|
if publish_flags.dry_run {
|
||||||
for (_, package) in prepared_data.package_by_name {
|
for (_, package) in prepared_data.package_by_name {
|
||||||
log::info!(
|
log::info!(
|
||||||
|
@ -1003,15 +1012,6 @@ pub async fn publish(
|
||||||
return Ok(());
|
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(
|
perform_publish(
|
||||||
cli_factory.http_client(),
|
cli_factory.http_client(),
|
||||||
prepared_data.publish_order_graph,
|
prepared_data.publish_order_graph,
|
||||||
|
|
|
@ -708,3 +708,34 @@ fn allow_dirty_not_in_repo() {
|
||||||
let output = output.combined_output();
|
let output = output.combined_output();
|
||||||
assert_contains!(output, "Successfully published");
|
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