File tree Expand file tree Collapse file tree 3 files changed +22
-7
lines changed Expand file tree Collapse file tree 3 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -418,8 +418,15 @@ pub struct SelfNamespace {
418
418
#[ derive( Subcommand ) ]
419
419
#[ cfg( feature = "self-update" ) ]
420
420
pub enum SelfCommand {
421
- /// Update uv to the latest version.
422
- Update ,
421
+ /// Update uv.
422
+ Update ( SelfUpdateArgs ) ,
423
+ }
424
+
425
+ #[ derive( Args , Debug ) ]
426
+ #[ cfg( feature = "self-update" ) ]
427
+ pub struct SelfUpdateArgs {
428
+ /// Update to the specified version. If not provided, uv will update to the latest version.
429
+ pub target_version : Option < String > ,
423
430
}
424
431
425
432
#[ derive( Args ) ]
Original file line number Diff line number Diff line change 1
1
use std:: fmt:: Write ;
2
2
3
3
use anyhow:: Result ;
4
- use axoupdater:: { AxoUpdater , AxoupdateError } ;
4
+ use axoupdater:: { AxoUpdater , AxoupdateError , UpdateRequest } ;
5
5
use owo_colors:: OwoColorize ;
6
6
use tracing:: debug;
7
7
@@ -11,7 +11,7 @@ use crate::commands::ExitStatus;
11
11
use crate :: printer:: Printer ;
12
12
13
13
/// Attempt to update the uv binary.
14
- pub ( crate ) async fn self_update ( printer : Printer ) -> Result < ExitStatus > {
14
+ pub ( crate ) async fn self_update ( version : Option < String > , printer : Printer ) -> Result < ExitStatus > {
15
15
let mut updater = AxoUpdater :: new_for ( "uv" ) ;
16
16
updater. disable_installer_output ( ) ;
17
17
@@ -70,6 +70,14 @@ pub(crate) async fn self_update(printer: Printer) -> Result<ExitStatus> {
70
70
)
71
71
) ?;
72
72
73
+ let update_request = if let Some ( version) = version {
74
+ UpdateRequest :: SpecificTag ( version)
75
+ } else {
76
+ UpdateRequest :: Latest
77
+ } ;
78
+
79
+ updater. configure_version_specifier ( update_request) ;
80
+
73
81
// Run the updater. This involves a network request, since we need to determine the latest
74
82
// available version of uv.
75
83
match updater. run ( ) . await {
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ use uv_cli::{
18
18
} ;
19
19
use uv_cli:: { PythonCommand , PythonNamespace , ToolCommand , ToolNamespace } ;
20
20
#[ cfg( feature = "self-update" ) ]
21
- use uv_cli:: { SelfCommand , SelfNamespace } ;
21
+ use uv_cli:: { SelfCommand , SelfNamespace , SelfUpdateArgs } ;
22
22
use uv_fs:: CWD ;
23
23
use uv_requirements:: RequirementsSource ;
24
24
use uv_scripts:: Pep723Script ;
@@ -766,8 +766,8 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
766
766
}
767
767
#[ cfg( feature = "self-update" ) ]
768
768
Commands :: Self_ ( SelfNamespace {
769
- command : SelfCommand :: Update ,
770
- } ) => commands:: self_update ( printer) . await ,
769
+ command : SelfCommand :: Update ( SelfUpdateArgs { target_version } ) ,
770
+ } ) => commands:: self_update ( target_version , printer) . await ,
771
771
Commands :: Version { output_format } => {
772
772
commands:: version ( output_format, & mut stdout ( ) ) ?;
773
773
Ok ( ExitStatus :: Success )
You can’t perform that action at this time.
0 commit comments