/
githubmirror
/
deno
Обзор
Документация
Войти
/
githubmirror
/
deno
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v2.8.2
cli/util/git.rs
47 строк
1 KB
Marvin Hagemeister
feat: add `deno pack` command to create npm tarballs (#32139)
06 май 2026, 11:23
Не верифицирован
06 май 2026, 11:23
0b92830
Код
Авторство
О чём код?
// Copyright 2018-2026 the Deno authors. MIT license. use std::path::Path; use std::process::Stdio; use tokio::process::Command; pub async fn check_if_git_repo_dirty(cwd: &Path) -> Option<String> { let bin_name = if cfg!(windows) { "git.exe" } else { "git" }; // Check if git exists let git_exists = Command::new(bin_name) .arg("--version") .stderr(Stdio::null()) .stdout(Stdio::null()) .status() .await .is_ok_and(|status| status.success()); if !git_exists { return None; // Git is not installed } // Check if there are uncommitted changes. If git fails (killed, // permissions, repo missing), treat it the same as "git not installed": // we just don't have a working-tree signal, so don't block the user. let Ok(output) = Command::new(bin_name) .current_dir(cwd) .args(["status", "--porcelain"]) .output() .await else { return None; }; if !output.status.success() { return None; } let output_str = String::from_utf8_lossy(&output.stdout); let text = output_str.trim(); if text.is_empty() { None } else { Some(text.to_string()) } }