mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix(publish): show dirty files on dirty check failure (#24541)
This commit is contained in:
parent
9510a8b7d1
commit
8243c85a47
2 changed files with 29 additions and 9 deletions
|
@ -143,10 +143,14 @@ pub async fn publish(
|
||||||
.ok()
|
.ok()
|
||||||
.is_none()
|
.is_none()
|
||||||
&& !publish_flags.allow_dirty
|
&& !publish_flags.allow_dirty
|
||||||
&& check_if_git_repo_dirty(cli_options.initial_cwd()).await
|
|
||||||
{
|
{
|
||||||
|
if let Some(dirty_text) =
|
||||||
|
check_if_git_repo_dirty(cli_options.initial_cwd()).await
|
||||||
|
{
|
||||||
|
log::error!("\nUncommitted changes:\n\n{}\n", dirty_text);
|
||||||
bail!("Aborting due to uncommitted changes. Check in source code or run with --allow-dirty");
|
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 {
|
||||||
|
@ -306,7 +310,10 @@ impl PublishPreparer {
|
||||||
} else if std::env::var("DENO_INTERNAL_FAST_CHECK_OVERWRITE").as_deref()
|
} else if std::env::var("DENO_INTERNAL_FAST_CHECK_OVERWRITE").as_deref()
|
||||||
== Ok("1")
|
== Ok("1")
|
||||||
{
|
{
|
||||||
if check_if_git_repo_dirty(self.cli_options.initial_cwd()).await {
|
if check_if_git_repo_dirty(self.cli_options.initial_cwd())
|
||||||
|
.await
|
||||||
|
.is_some()
|
||||||
|
{
|
||||||
bail!("When using DENO_INTERNAL_FAST_CHECK_OVERWRITE, the git repo must be in a clean state.");
|
bail!("When using DENO_INTERNAL_FAST_CHECK_OVERWRITE, the git repo must be in a clean state.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1130,7 +1137,7 @@ fn verify_version_manifest(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn check_if_git_repo_dirty(cwd: &Path) -> bool {
|
async fn check_if_git_repo_dirty(cwd: &Path) -> Option<String> {
|
||||||
let bin_name = if cfg!(windows) { "git.exe" } else { "git" };
|
let bin_name = if cfg!(windows) { "git.exe" } else { "git" };
|
||||||
|
|
||||||
// Check if git exists
|
// Check if git exists
|
||||||
|
@ -1143,7 +1150,7 @@ async fn check_if_git_repo_dirty(cwd: &Path) -> bool {
|
||||||
.map_or(false, |status| status.success());
|
.map_or(false, |status| status.success());
|
||||||
|
|
||||||
if !git_exists {
|
if !git_exists {
|
||||||
return false; // Git is not installed
|
return None; // Git is not installed
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there are uncommitted changes
|
// Check if there are uncommitted changes
|
||||||
|
@ -1155,7 +1162,12 @@ async fn check_if_git_repo_dirty(cwd: &Path) -> bool {
|
||||||
.expect("Failed to execute command");
|
.expect("Failed to execute command");
|
||||||
|
|
||||||
let output_str = String::from_utf8_lossy(&output.stdout);
|
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||||
!output_str.trim().is_empty()
|
let text = output_str.trim();
|
||||||
|
if text.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(text.to_string())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::print_stderr)]
|
#[allow(clippy::print_stderr)]
|
||||||
|
|
|
@ -413,8 +413,16 @@ fn allow_dirty() {
|
||||||
.arg("sadfasdf")
|
.arg("sadfasdf")
|
||||||
.run();
|
.run();
|
||||||
output.assert_exit_code(1);
|
output.assert_exit_code(1);
|
||||||
let output = output.combined_output();
|
output.assert_matches_text(r#"Check [WILDLINE]
|
||||||
assert_contains!(output, "Aborting due to uncommitted changes. Check in source code or run with --allow-dirty");
|
Checking for slow types in the public API...
|
||||||
|
|
||||||
|
Uncommitted changes:
|
||||||
|
|
||||||
|
?? deno.json
|
||||||
|
?? main.ts
|
||||||
|
|
||||||
|
error: Aborting due to uncommitted changes. Check in source code or run with --allow-dirty
|
||||||
|
"#);
|
||||||
|
|
||||||
let output = context
|
let output = context
|
||||||
.new_command()
|
.new_command()
|
||||||
|
|
Loading…
Reference in a new issue