From 3c70b9435a649a53614bd3ae6f434c2a455d575a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 12 Aug 2024 19:32:53 +0100 Subject: feat: `deno upgrade --rc` (#24905) This commit adds the "--rc" flag to "deno upgrade" subcommand. This flag allows to upgrade to the latest "release candidate" release. The update checker was also updated to take this into account. --- cli/args/flags.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'cli/args') diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 0c4b75f89..c6bb90430 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -398,6 +398,7 @@ pub struct TestFlags { pub struct UpgradeFlags { pub dry_run: bool, pub force: bool, + pub release_candidate: bool, pub canary: bool, pub version: Option, pub output: Option, @@ -2908,6 +2909,13 @@ update to a different location, use the --output flag: .help("Upgrade to canary builds") .action(ArgAction::SetTrue), ) + .arg( + Arg::new("release-candidate") + .long("rc") + .help("Upgrade to a release candidate") + .conflicts_with_all(["canary", "version"]) + .action(ArgAction::SetTrue), + ) .arg(ca_file_arg()) }) } @@ -4568,11 +4576,13 @@ fn upgrade_parse(flags: &mut Flags, matches: &mut ArgMatches) { let dry_run = matches.get_flag("dry-run"); let force = matches.get_flag("force"); let canary = matches.get_flag("canary"); + let release_candidate = matches.get_flag("release-candidate"); let version = matches.remove_one::("version"); let output = matches.remove_one::("output"); flags.subcommand = DenoSubcommand::Upgrade(UpgradeFlags { dry_run, force, + release_candidate, canary, version, output, @@ -5057,6 +5067,7 @@ mod tests { force: true, dry_run: true, canary: false, + release_candidate: false, version: None, output: None, }), @@ -5075,6 +5086,7 @@ mod tests { force: false, dry_run: false, canary: false, + release_candidate: false, version: None, output: Some(String::from("example.txt")), }), @@ -9039,6 +9051,7 @@ mod tests { force: false, dry_run: false, canary: false, + release_candidate: false, version: None, output: None, }), @@ -9048,6 +9061,31 @@ mod tests { ); } + #[test] + fn upgrade_release_candidate() { + let r = flags_from_vec(svec!["deno", "upgrade", "--rc"]); + assert_eq!( + r.unwrap(), + Flags { + subcommand: DenoSubcommand::Upgrade(UpgradeFlags { + force: false, + dry_run: false, + canary: false, + release_candidate: true, + version: None, + output: None, + }), + ..Flags::default() + } + ); + + let r = flags_from_vec(svec!["deno", "upgrade", "--rc", "--canary"]); + assert!(r.is_err()); + + let r = flags_from_vec(svec!["deno", "upgrade", "--rc", "--version"]); + assert!(r.is_err()); + } + #[test] fn cache_with_cafile() { let r = flags_from_vec(svec![ -- cgit v1.2.3