diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-02-28 09:21:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-28 10:21:12 +0100 |
commit | c2c4e745a5db4f2e53aa70bf22b6c828fa1b4040 (patch) | |
tree | a63f5933e6082589ddf60ab7b16e97c1a7b7392d /tests | |
parent | 96cfe82664c07163930444e835437ea0c44e5332 (diff) |
fix(publish): error if there are uncommitted changes (#22613)
Closes https://github.com/denoland/deno/issues/22330
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/publish_tests.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/integration/publish_tests.rs b/tests/integration/publish_tests.rs index fafc018f9..23db5d7de 100644 --- a/tests/integration/publish_tests.rs +++ b/tests/integration/publish_tests.rs @@ -1,5 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use std::process::Command; + use deno_core::serde_json::json; use test_util::assert_contains; use test_util::assert_not_contains; @@ -427,3 +429,44 @@ fn publish_context_builder() -> TestContextBuilder { .envs(env_vars_for_jsr_tests()) .use_temp_cwd() } + +#[test] +fn allow_dirty() { + let context = publish_context_builder().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("--token") + .arg("sadfasdf") + .run(); + output.assert_exit_code(1); + let output = output.combined_output(); + assert_contains!(output, "Aborting due to uncomitted changes"); + + let output = context + .new_command() + .arg("publish") + .arg("--allow-dirty") + .arg("--token") + .arg("sadfasdf") + .run(); + output.assert_exit_code(0); + let output = output.combined_output(); + assert_contains!(output, "Successfully published"); +} |