mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-02 01:52:22 +00:00
Remove uv version
fallback (#14161)
Fixes #14157 --------- Co-authored-by: John Mumm <jtfmumm@gmail.com>
This commit is contained in:
parent
0eb5b1f422
commit
b15d59b4ad
3 changed files with 16 additions and 55 deletions
|
@ -19,7 +19,6 @@ use uv_pep440::{BumpCommand, PrereleaseKind, Version};
|
|||
use uv_pep508::PackageName;
|
||||
use uv_python::{PythonDownloads, PythonPreference, PythonRequest};
|
||||
use uv_settings::PythonInstallMirrors;
|
||||
use uv_warnings::warn_user;
|
||||
use uv_workspace::pyproject_mut::Error;
|
||||
use uv_workspace::{
|
||||
DiscoveryOptions, WorkspaceCache,
|
||||
|
@ -58,7 +57,6 @@ pub(crate) async fn project_version(
|
|||
mut bump: Vec<VersionBump>,
|
||||
short: bool,
|
||||
output_format: VersionFormat,
|
||||
strict: bool,
|
||||
project_dir: &Path,
|
||||
package: Option<PackageName>,
|
||||
dry_run: bool,
|
||||
|
@ -80,21 +78,7 @@ pub(crate) async fn project_version(
|
|||
preview: PreviewMode,
|
||||
) -> Result<ExitStatus> {
|
||||
// Read the metadata
|
||||
let project = match find_target(project_dir, package.as_ref()).await {
|
||||
Ok(target) => target,
|
||||
Err(err) => {
|
||||
// If strict, hard bail on failing to find the pyproject.toml
|
||||
if strict {
|
||||
return Err(err)?;
|
||||
}
|
||||
// Otherwise, warn and provide fallback to the old `uv version` from before 0.7.0
|
||||
warn_user!(
|
||||
"Failed to read project metadata ({err}). Running `{}` for compatibility. This fallback will be removed in the future; pass `--preview` to force an error.",
|
||||
"uv self version".green()
|
||||
);
|
||||
return self_version(short, output_format, printer);
|
||||
}
|
||||
};
|
||||
let project = find_target(project_dir, package.as_ref()).await?;
|
||||
|
||||
let pyproject_path = project.root().join("pyproject.toml");
|
||||
let Some(name) = project.project_name().cloned() else {
|
||||
|
|
|
@ -1059,7 +1059,6 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
|
|||
}
|
||||
Commands::Project(project) => {
|
||||
Box::pin(run_project(
|
||||
cli.top_level.global_args.project.is_some(),
|
||||
project,
|
||||
&project_dir,
|
||||
run_command,
|
||||
|
@ -1660,7 +1659,6 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
|
|||
|
||||
/// Run a [`ProjectCommand`].
|
||||
async fn run_project(
|
||||
project_was_explicit: bool,
|
||||
project_command: Box<ProjectCommand>,
|
||||
project_dir: &Path,
|
||||
command: Option<RunCommand>,
|
||||
|
@ -2052,19 +2050,11 @@ async fn run_project(
|
|||
.combine(Refresh::from(args.settings.resolver.upgrade.clone())),
|
||||
);
|
||||
|
||||
// If they specified any of these flags, they probably don't mean `uv self version`
|
||||
let strict = project_was_explicit
|
||||
|| globals.preview.is_enabled()
|
||||
|| args.dry_run
|
||||
|| !args.bump.is_empty()
|
||||
|| args.value.is_some()
|
||||
|| args.package.is_some();
|
||||
Box::pin(commands::project_version(
|
||||
args.value,
|
||||
args.bump,
|
||||
args.short,
|
||||
args.output_format,
|
||||
strict,
|
||||
project_dir,
|
||||
args.package,
|
||||
args.dry_run,
|
||||
|
|
|
@ -1437,8 +1437,8 @@ fn version_set_dynamic() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// Should fallback to `uv --version` if this pyproject.toml isn't usable for whatever reason
|
||||
// (In this case, because tool.uv.managed = false)
|
||||
/// Previously would fallback to `uv --version` if this pyproject.toml isn't usable for whatever reason
|
||||
/// (In this case, because tool.uv.managed = false)
|
||||
#[test]
|
||||
fn version_get_fallback_unmanaged() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
@ -1456,13 +1456,12 @@ fn version_get_fallback_unmanaged() -> Result<()> {
|
|||
)?;
|
||||
|
||||
uv_snapshot!(context.filters(), context.version(), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
success: false
|
||||
exit_code: 2
|
||||
----- stdout -----
|
||||
uv [VERSION] ([COMMIT] DATE)
|
||||
|
||||
----- stderr -----
|
||||
warning: Failed to read project metadata (The project is marked as unmanaged: `[TEMP_DIR]/`). Running `uv self version` for compatibility. This fallback will be removed in the future; pass `--preview` to force an error.
|
||||
error: The project is marked as unmanaged: `[TEMP_DIR]/`
|
||||
");
|
||||
|
||||
let pyproject = fs_err::read_to_string(&pyproject_toml)?;
|
||||
|
@ -1507,13 +1506,12 @@ fn version_get_fallback_unmanaged_short() -> Result<()> {
|
|||
.collect::<Vec<_>>();
|
||||
uv_snapshot!(filters, context.version()
|
||||
.arg("--short"), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
success: false
|
||||
exit_code: 2
|
||||
----- stdout -----
|
||||
[VERSION] ([COMMIT] DATE)
|
||||
|
||||
----- stderr -----
|
||||
warning: Failed to read project metadata (The project is marked as unmanaged: `[TEMP_DIR]/`). Running `uv self version` for compatibility. This fallback will be removed in the future; pass `--preview` to force an error.
|
||||
error: The project is marked as unmanaged: `[TEMP_DIR]/`
|
||||
");
|
||||
|
||||
let pyproject = fs_err::read_to_string(&pyproject_toml)?;
|
||||
|
@ -1587,25 +1585,14 @@ fn version_get_fallback_unmanaged_json() -> Result<()> {
|
|||
.collect::<Vec<_>>();
|
||||
if git_version_info_expected() {
|
||||
uv_snapshot!(filters, context.version()
|
||||
.arg("--output-format").arg("json"), @r#"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
{
|
||||
"package_name": "uv",
|
||||
"version": "[VERSION]",
|
||||
"commit_info": {
|
||||
"short_commit_hash": "[LONGHASH]",
|
||||
"commit_hash": "[LONGHASH]",
|
||||
"commit_date": "[DATE]",
|
||||
"last_tag": "[TAG]",
|
||||
"commits_since_last_tag": [COUNT]
|
||||
}
|
||||
}
|
||||
.arg("--output-format").arg("json"), @r"
|
||||
success: false
|
||||
exit_code: 2
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
warning: Failed to read project metadata (The project is marked as unmanaged: `[TEMP_DIR]/`). Running `uv self version` for compatibility. This fallback will be removed in the future; pass `--preview` to force an error.
|
||||
"#);
|
||||
----- stderr -----
|
||||
error: The project is marked as unmanaged: `[TEMP_DIR]/`
|
||||
");
|
||||
} else {
|
||||
uv_snapshot!(filters, context.version()
|
||||
.arg("--output-format").arg("json"), @r#"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue