3 use xshell::{cmd, pushd, read_dir, read_file, write_file};
5 use crate::{date_iso, flags, is_release_tag, project_root, Result};
8 pub(crate) fn run(self) -> Result<()> {
10 cmd!("git switch release").run()?;
11 cmd!("git fetch upstream --tags --force").run()?;
12 cmd!("git reset --hard tags/nightly").run()?;
13 // The `release` branch sometimes has a couple of cherry-picked
14 // commits for patch releases. If that's the case, just overwrite
15 // it. As we are setting `release` branch to an up-to-date `nightly`
16 // tag, this shouldn't be problematic in general.
18 // Note that, as we tag releases, we don't worry about "losing"
19 // commits -- they'll be kept alive by the tag. More generally, we
20 // don't care about historic releases all that much, it's fine even
21 // to delete old tags.
22 cmd!("git push --force").run()?;
25 // Generates bits of manual.adoc.
26 cmd!("cargo test -p ide_assists -p ide_diagnostics -p rust-analyzer -- sourcegen_")
29 let website_root = project_root().join("../rust-analyzer.github.io");
31 let _dir = pushd(&website_root)?;
32 cmd!("git switch src").run()?;
33 cmd!("git pull").run()?;
35 let changelog_dir = website_root.join("./thisweek/_posts");
37 let today = date_iso()?;
38 let commit = cmd!("git rev-parse HEAD").read()?;
39 let changelog_n = read_dir(changelog_dir.as_path())?.len();
43 "generated_assists.adoc",
44 "generated_config.adoc",
45 "generated_diagnostic.adoc",
46 "generated_features.adoc",
48 let src = project_root().join("./docs/user/").join(adoc);
49 let dst = website_root.join(adoc);
51 let contents = read_file(src)?;
52 write_file(dst, contents)?;
55 let tags = cmd!("git tag --list").read()?;
56 let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap();
58 let contents = changelog::get_changelog(changelog_n, &commit, prev_tag, &today)?;
59 let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n));
60 write_file(&path, &contents)?;
67 pub(crate) fn run(self) -> Result<()> {
68 let _dir = pushd("../rust-rust-analyzer")?;
69 cmd!("git switch master").run()?;
70 cmd!("git fetch upstream").run()?;
71 cmd!("git reset --hard upstream/master").run()?;
72 cmd!("git submodule update --recursive").run()?;
74 let branch = format!("rust-analyzer-{}", date_iso()?);
75 cmd!("git switch -c {branch}").run()?;
77 let _dir = pushd("src/tools/rust-analyzer")?;
78 cmd!("git fetch origin").run()?;
79 cmd!("git reset --hard origin/release").run()?;
81 cmd!("git add src/tools/rust-analyzer").run()?;
82 cmd!("git commit -m':arrow_up: rust-analyzer'").run()?;
84 cmd!("git push -u origin {branch}").run()?;
85 cmd!("xdg-open https://github.com/matklad/rust/pull/new/{branch}?body=r%3F%20%40ghost")