diff options
Diffstat (limited to 'xtask/src/lib.rs')
-rw-r--r-- | xtask/src/lib.rs | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 9b0afe8e0..1bb1882b0 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs | |||
@@ -15,7 +15,10 @@ use std::{ | |||
15 | process::{Command, Stdio}, | 15 | process::{Command, Stdio}, |
16 | }; | 16 | }; |
17 | 17 | ||
18 | use crate::{cmd::run, codegen::Mode}; | 18 | use crate::{ |
19 | cmd::{run, run_with_output}, | ||
20 | codegen::Mode, | ||
21 | }; | ||
19 | 22 | ||
20 | pub use anyhow::Result; | 23 | pub use anyhow::Result; |
21 | 24 | ||
@@ -53,8 +56,7 @@ fn reformat(text: impl std::fmt::Display) -> Result<String> { | |||
53 | write!(rustfmt.stdin.take().unwrap(), "{}", text)?; | 56 | write!(rustfmt.stdin.take().unwrap(), "{}", text)?; |
54 | let output = rustfmt.wait_with_output()?; | 57 | let output = rustfmt.wait_with_output()?; |
55 | let stdout = String::from_utf8(output.stdout)?; | 58 | let stdout = String::from_utf8(output.stdout)?; |
56 | // TODO: update the preable: replace ra_tools with the relevant path | 59 | let preamble = "Generated file, do not edit by hand, see `xtask/src/codegen`"; |
57 | let preamble = "Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`"; | ||
58 | Ok(format!("//! {}\n\n{}", preamble, stdout)) | 60 | Ok(format!("//! {}\n\n{}", preamble, stdout)) |
59 | } | 61 | } |
60 | 62 | ||
@@ -157,3 +159,41 @@ fn rm_rf(path: &Path) -> Result<()> { | |||
157 | if path.is_file() { fs::remove_file(path) } else { fs::remove_dir_all(path) } | 159 | if path.is_file() { fs::remove_file(path) } else { fs::remove_dir_all(path) } |
158 | .with_context(|| format!("failed to remove {:?}", path)) | 160 | .with_context(|| format!("failed to remove {:?}", path)) |
159 | } | 161 | } |
162 | |||
163 | pub fn run_release() -> Result<()> { | ||
164 | run("git switch release", ".")?; | ||
165 | run("git fetch upstream", ".")?; | ||
166 | run("git reset --hard upstream/master", ".")?; | ||
167 | run("git push", ".")?; | ||
168 | |||
169 | let changelog_dir = project_root().join("../rust-analyzer.github.io/thisweek/_posts"); | ||
170 | |||
171 | let today = run_with_output("date --iso", ".")?; | ||
172 | let commit = run_with_output("git rev-parse HEAD", ".")?; | ||
173 | let changelog_n = fs::read_dir(changelog_dir.as_path())?.count(); | ||
174 | |||
175 | let contents = format!( | ||
176 | "\ | ||
177 | = Changelog #{} | ||
178 | :sectanchors: | ||
179 | :page-layout: post | ||
180 | |||
181 | Commit: commit:{}[] + | ||
182 | Release: release:{}[] | ||
183 | |||
184 | == New Features | ||
185 | |||
186 | * pr:[] . | ||
187 | |||
188 | == Fixes | ||
189 | |||
190 | == Internal Improvements | ||
191 | ", | ||
192 | changelog_n, commit, today | ||
193 | ); | ||
194 | |||
195 | let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); | ||
196 | fs::write(&path, &contents)?; | ||
197 | |||
198 | Ok(()) | ||
199 | } | ||