aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xtask/src/main.rs7
-rw-r--r--xtask/src/not_bash.rs12
-rw-r--r--xtask/src/release.rs31
3 files changed, 47 insertions, 3 deletions
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index f7a79362d..f447613d4 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -17,7 +17,7 @@ use xtask::{
17 install::{ClientOpt, InstallCmd, ServerOpt}, 17 install::{ClientOpt, InstallCmd, ServerOpt},
18 not_bash::pushd, 18 not_bash::pushd,
19 pre_commit, project_root, 19 pre_commit, project_root,
20 release::ReleaseCmd, 20 release::{PromoteCmd, ReleaseCmd},
21 run_clippy, run_fuzzer, run_pre_cache, run_rustfmt, Result, 21 run_clippy, run_fuzzer, run_pre_cache, run_rustfmt, Result,
22}; 22};
23 23
@@ -105,6 +105,11 @@ FLAGS:
105 args.finish()?; 105 args.finish()?;
106 ReleaseCmd { dry_run }.run() 106 ReleaseCmd { dry_run }.run()
107 } 107 }
108 "promote" => {
109 let dry_run = args.contains("--dry-run");
110 args.finish()?;
111 PromoteCmd { dry_run }.run()
112 }
108 "dist" => { 113 "dist" => {
109 let nightly = args.contains("--nightly"); 114 let nightly = args.contains("--nightly");
110 let client_version: Option<String> = args.opt_value_from_str("--client")?; 115 let client_version: Option<String> = args.opt_value_from_str("--client")?;
diff --git a/xtask/src/not_bash.rs b/xtask/src/not_bash.rs
index a6431e586..8844fa216 100644
--- a/xtask/src/not_bash.rs
+++ b/xtask/src/not_bash.rs
@@ -153,7 +153,17 @@ fn run_process_inner(cmd: &str, echo: bool, stdin: Option<&[u8]>) -> Result<Stri
153 153
154// FIXME: some real shell lexing here 154// FIXME: some real shell lexing here
155fn shelx(cmd: &str) -> Vec<String> { 155fn shelx(cmd: &str) -> Vec<String> {
156 cmd.split_whitespace().map(|it| it.to_string()).collect() 156 let mut res = Vec::new();
157 for (string_piece, in_quotes) in cmd.split('\'').zip([false, true].iter().copied().cycle()) {
158 if in_quotes {
159 res.push(string_piece.to_string())
160 } else {
161 if !string_piece.is_empty() {
162 res.extend(string_piece.split_ascii_whitespace().map(|it| it.to_string()))
163 }
164 }
165 }
166 res
157} 167}
158 168
159struct Env { 169struct Env {
diff --git a/xtask/src/release.rs b/xtask/src/release.rs
index 46992c1ca..170cfee9f 100644
--- a/xtask/src/release.rs
+++ b/xtask/src/release.rs
@@ -1,6 +1,6 @@
1use crate::{ 1use crate::{
2 codegen, is_release_tag, 2 codegen, is_release_tag,
3 not_bash::{date_iso, fs2, run}, 3 not_bash::{date_iso, fs2, pushd, run},
4 project_root, Mode, Result, 4 project_root, Mode, Result,
5}; 5};
6 6
@@ -69,3 +69,32 @@ Release: release:{}[]
69 Ok(()) 69 Ok(())
70 } 70 }
71} 71}
72
73pub struct PromoteCmd {
74 pub dry_run: bool,
75}
76
77impl PromoteCmd {
78 pub fn run(self) -> Result<()> {
79 let _dir = pushd("../rust-rust-analyzer");
80 run!("git switch master")?;
81 run!("git fetch upstream")?;
82 run!("git reset --hard upstream/master")?;
83 run!("git submodule update --recursive")?;
84
85 let branch = format!("rust-analyzer-{}", date_iso()?);
86 run!("git switch -c {}", branch)?;
87 {
88 let _dir = pushd("src/tools/rust-analyzer");
89 run!("git fetch origin")?;
90 run!("git reset --hard origin/release")?;
91 }
92 run!("git add src/tools/rust-analyzer")?;
93 run!("git commit -m':arrow_up: rust-analyzer'")?;
94 if !self.dry_run {
95 run!("git push")?;
96 run!("xdg-open https://github.com/matklad/rust/pull/new/{}", branch)?;
97 }
98 Ok(())
99 }
100}