mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 14:03:35 +00:00
Make minor improvements and cleanups
This commit is contained in:
parent
0c6fd4dbe5
commit
fccc094712
2 changed files with 17 additions and 18 deletions
|
@ -16,9 +16,9 @@ impl flags::PublishReleaseNotes {
|
||||||
format!("\nSee also [original changelog]({original_changelog_url}).");
|
format!("\nSee also [original changelog]({original_changelog_url}).");
|
||||||
markdown.push_str(&additional_paragraph);
|
markdown.push_str(&additional_paragraph);
|
||||||
if self.dry_run {
|
if self.dry_run {
|
||||||
println!("{}", markdown);
|
println!("{markdown}");
|
||||||
} else {
|
} else {
|
||||||
update_release(sh, &tag_name, &markdown)?;
|
update_release(sh, tag_name, &markdown)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ fn update_release(sh: &Shell, tag_name: &str, release_notes: &str) -> Result<()>
|
||||||
Err(_) => bail!("Please obtain a personal access token from https://github.com/settings/tokens and set the `GITHUB_TOKEN` environment variable."),
|
Err(_) => bail!("Please obtain a personal access token from https://github.com/settings/tokens and set the `GITHUB_TOKEN` environment variable."),
|
||||||
};
|
};
|
||||||
let accept = "Accept: application/vnd.github+json";
|
let accept = "Accept: application/vnd.github+json";
|
||||||
let authorization = format!("Authorization: Bearer {}", token);
|
let authorization = format!("Authorization: Bearer {token}");
|
||||||
let api_version = "X-GitHub-Api-Version: 2022-11-28";
|
let api_version = "X-GitHub-Api-Version: 2022-11-28";
|
||||||
let release_url = "https://api.github.com/repos/rust-lang/rust-analyzer/releases";
|
let release_url = "https://api.github.com/repos/rust-lang/rust-analyzer/releases";
|
||||||
|
|
||||||
|
@ -80,10 +80,10 @@ fn update_release(sh: &Shell, tag_name: &str, release_notes: &str) -> Result<()>
|
||||||
|
|
||||||
let mut patch = String::new();
|
let mut patch = String::new();
|
||||||
write_json::object(&mut patch)
|
write_json::object(&mut patch)
|
||||||
.string("tag_name", &tag_name)
|
.string("tag_name", tag_name)
|
||||||
.string("target_commitish", "master")
|
.string("target_commitish", "master")
|
||||||
.string("name", &tag_name)
|
.string("name", tag_name)
|
||||||
.string("body", &release_notes)
|
.string("body", release_notes)
|
||||||
.bool("draft", false)
|
.bool("draft", false)
|
||||||
.bool("prerelease", false);
|
.bool("prerelease", false);
|
||||||
let _ = cmd!(
|
let _ = cmd!(
|
||||||
|
@ -102,7 +102,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn original_changelog_url_creation() {
|
fn original_changelog_url_creation() {
|
||||||
let input = "2019-07-24-changelog-0.adoc";
|
let input = "2019-07-24-changelog-0.adoc";
|
||||||
let actual = create_original_changelog_url(&input);
|
let actual = create_original_changelog_url(input);
|
||||||
let expected = "https://rust-analyzer.github.io/thisweek/2019/07/24/changelog-0.html";
|
let expected = "https://rust-analyzer.github.io/thisweek/2019/07/24/changelog-0.html";
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ use std::{
|
||||||
iter::Peekable,
|
iter::Peekable,
|
||||||
};
|
};
|
||||||
|
|
||||||
const LISTING_DELIMITER: &'static str = "----";
|
const LISTING_DELIMITER: &str = "----";
|
||||||
const IMAGE_BLOCK_PREFIX: &'static str = "image::";
|
const IMAGE_BLOCK_PREFIX: &str = "image::";
|
||||||
const VIDEO_BLOCK_PREFIX: &'static str = "video::";
|
const VIDEO_BLOCK_PREFIX: &str = "video::";
|
||||||
|
|
||||||
struct Converter<'a, 'b, R: BufRead> {
|
struct Converter<'a, 'b, R: BufRead> {
|
||||||
iter: &'a mut Peekable<Lines<R>>,
|
iter: &'a mut Peekable<Lines<R>>,
|
||||||
|
@ -89,7 +89,7 @@ impl<'a, 'b, R: BufRead> Converter<'a, 'b, R> {
|
||||||
while let Some(line) = self.iter.peek() {
|
while let Some(line) = self.iter.peek() {
|
||||||
let line = line.as_deref().map_err(|e| anyhow!("{e}"))?;
|
let line = line.as_deref().map_err(|e| anyhow!("{e}"))?;
|
||||||
|
|
||||||
if get_list_item(&line).is_some() {
|
if get_list_item(line).is_some() {
|
||||||
let line = self.iter.next().unwrap()?;
|
let line = self.iter.next().unwrap()?;
|
||||||
let line = process_inline_macros(&line)?;
|
let line = process_inline_macros(&line)?;
|
||||||
let (marker, item) = get_list_item(&line).unwrap();
|
let (marker, item) = get_list_item(&line).unwrap();
|
||||||
|
@ -253,17 +253,16 @@ impl<'a, 'b, R: BufRead> Converter<'a, 'b, R> {
|
||||||
{
|
{
|
||||||
while let Some(line) = self.iter.peek() {
|
while let Some(line) = self.iter.peek() {
|
||||||
let line = line.as_deref().map_err(|e| anyhow!("{e}"))?;
|
let line = line.as_deref().map_err(|e| anyhow!("{e}"))?;
|
||||||
if predicate(&line) {
|
if predicate(line) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.write_indent(level);
|
self.write_indent(level);
|
||||||
let line = self.iter.next().unwrap()?;
|
let line = self.iter.next().unwrap()?;
|
||||||
let line = line.trim_start();
|
let line = line.trim_start();
|
||||||
let line = process_inline_macros(&line)?;
|
let line = process_inline_macros(line)?;
|
||||||
if line.ends_with('+') {
|
if let Some(stripped) = line.strip_suffix('+') {
|
||||||
let line = &line[..(line.len() - 1)];
|
self.output.push_str(stripped);
|
||||||
self.output.push_str(line);
|
|
||||||
self.output.push('\\');
|
self.output.push('\\');
|
||||||
} else {
|
} else {
|
||||||
self.output.push_str(&line);
|
self.output.push_str(&line);
|
||||||
|
@ -339,8 +338,8 @@ fn get_title(line: &str) -> Option<(usize, &str)> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_list_item(line: &str) -> Option<(ListMarker, &str)> {
|
fn get_list_item(line: &str) -> Option<(ListMarker, &str)> {
|
||||||
const HYPHYEN_MARKER: &'static str = "- ";
|
const HYPHEN_MARKER: &str = "- ";
|
||||||
if let Some(text) = line.strip_prefix(HYPHYEN_MARKER) {
|
if let Some(text) = line.strip_prefix(HYPHEN_MARKER) {
|
||||||
Some((ListMarker::Hyphen, text))
|
Some((ListMarker::Hyphen, text))
|
||||||
} else if let Some((count, text)) = strip_prefix_symbol(line, '*') {
|
} else if let Some((count, text)) = strip_prefix_symbol(line, '*') {
|
||||||
Some((ListMarker::Asterisk(count), text))
|
Some((ListMarker::Asterisk(count), text))
|
||||||
|
|
Loading…
Reference in a new issue