3 use xshell
::{cmd, Shell}
;
5 use crate::{date_iso, flags, is_release_tag, project_root}
;
8 pub(crate) fn run(self, sh
: &Shell
) -> anyhow
::Result
<()> {
10 cmd
!(sh
, "git switch release").run()?
;
11 cmd
!(sh
, "git fetch upstream --tags --force").run()?
;
12 cmd
!(sh
, "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
!(sh
, "git push --force").run()?
;
25 // Generates bits of manual.adoc.
26 cmd
!(sh
, "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
= sh
.push_dir(&website_root
);
32 cmd
!(sh
, "git switch src").run()?
;
33 cmd
!(sh
, "git pull").run()?
;
35 let changelog_dir
= website_root
.join("./thisweek/_posts");
37 let today
= date_iso(sh
)?
;
38 let commit
= cmd
!(sh
, "git rev-parse HEAD").read()?
;
40 .read_dir(changelog_dir
.as_path())?
42 .filter_map(|p
| p
.file_stem().map(|s
| s
.to_string_lossy().to_string()))
43 .filter_map(|s
| s
.splitn(5, '
-'
).last().map(|n
| n
.replace('
-'
, ".")))
44 .filter_map(|s
| s
.parse
::<f32>().ok())
45 .map(|n
| 1 + n
.floor() as usize)
51 "generated_assists.adoc",
52 "generated_config.adoc",
53 "generated_diagnostic.adoc",
54 "generated_features.adoc",
56 let src
= project_root().join("./docs/user/").join(adoc
);
57 let dst
= website_root
.join(adoc
);
59 let contents
= sh
.read_file(src
)?
;
60 sh
.write_file(dst
, contents
)?
;
63 let tags
= cmd
!(sh
, "git tag --list").read()?
;
64 let prev_tag
= tags
.lines().filter(|line
| is_release_tag(line
)).last().unwrap();
66 let contents
= changelog
::get_changelog(sh
, changelog_n
, &commit
, prev_tag
, &today
)?
;
67 let path
= changelog_dir
.join(format
!("{today}-changelog-{changelog_n}.adoc"));
68 sh
.write_file(path
, contents
)?
;
75 pub(crate) fn run(self, sh
: &Shell
) -> anyhow
::Result
<()> {
76 let _dir
= sh
.push_dir("../rust-rust-analyzer");
77 cmd
!(sh
, "git switch master").run()?
;
78 cmd
!(sh
, "git fetch upstream").run()?
;
79 cmd
!(sh
, "git reset --hard upstream/master").run()?
;
81 let date
= date_iso(sh
)?
;
82 let branch
= format
!("rust-analyzer-{date}");
83 cmd
!(sh
, "git switch -c {branch}").run()?
;
84 cmd
!(sh
, "git subtree pull -m ':arrow_up: rust-analyzer' -P src/tools/rust-analyzer rust-analyzer release").run()?
;
87 cmd
!(sh
, "git push -u origin {branch}").run()?
;
90 "xdg-open https://github.com/matklad/rust/pull/new/{branch}?body=r%3F%20%40ghost"