summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tools/registry/mod.rs18
-rw-r--r--tests/integration/publish_tests.rs31
2 files changed, 40 insertions, 9 deletions
diff --git a/cli/tools/registry/mod.rs b/cli/tools/registry/mod.rs
index e323c6c79..b40aeaeb4 100644
--- a/cli/tools/registry/mod.rs
+++ b/cli/tools/registry/mod.rs
@@ -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,
diff --git a/tests/integration/publish_tests.rs b/tests/integration/publish_tests.rs
index f6ee1b371..a033f5d07 100644
--- a/tests/integration/publish_tests.rs
+++ b/tests/integration/publish_tests.rs
@@ -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");
+}