mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
Make minor improvements and cleanups
This commit is contained in:
parent
0c6fd4dbe5
commit
fccc094712
@ -16,9 +16,9 @@ impl flags::PublishReleaseNotes {
|
||||
format!("\nSee also [original changelog]({original_changelog_url}).");
|
||||
markdown.push_str(&additional_paragraph);
|
||||
if self.dry_run {
|
||||
println!("{}", markdown);
|
||||
println!("{markdown}");
|
||||
} else {
|
||||
update_release(sh, &tag_name, &markdown)?;
|
||||
update_release(sh, tag_name, &markdown)?;
|
||||
}
|
||||
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."),
|
||||
};
|
||||
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 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();
|
||||
write_json::object(&mut patch)
|
||||
.string("tag_name", &tag_name)
|
||||
.string("tag_name", tag_name)
|
||||
.string("target_commitish", "master")
|
||||
.string("name", &tag_name)
|
||||
.string("body", &release_notes)
|
||||
.string("name", tag_name)
|
||||
.string("body", release_notes)
|
||||
.bool("draft", false)
|
||||
.bool("prerelease", false);
|
||||
let _ = cmd!(
|
||||
@ -102,7 +102,7 @@ mod tests {
|
||||
#[test]
|
||||
fn original_changelog_url_creation() {
|
||||
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";
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ use std::{
|
||||
iter::Peekable,
|
||||
};
|
||||
|
||||
const LISTING_DELIMITER: &'static str = "----";
|
||||
const IMAGE_BLOCK_PREFIX: &'static str = "image::";
|
||||
const VIDEO_BLOCK_PREFIX: &'static str = "video::";
|
||||
const LISTING_DELIMITER: &str = "----";
|
||||
const IMAGE_BLOCK_PREFIX: &str = "image::";
|
||||
const VIDEO_BLOCK_PREFIX: &str = "video::";
|
||||
|
||||
struct Converter<'a, 'b, R: BufRead> {
|
||||
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() {
|
||||
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 = process_inline_macros(&line)?;
|
||||
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() {
|
||||
let line = line.as_deref().map_err(|e| anyhow!("{e}"))?;
|
||||
if predicate(&line) {
|
||||
if predicate(line) {
|
||||
break;
|
||||
}
|
||||
|
||||
self.write_indent(level);
|
||||
let line = self.iter.next().unwrap()?;
|
||||
let line = line.trim_start();
|
||||
let line = process_inline_macros(&line)?;
|
||||
if line.ends_with('+') {
|
||||
let line = &line[..(line.len() - 1)];
|
||||
self.output.push_str(line);
|
||||
let line = process_inline_macros(line)?;
|
||||
if let Some(stripped) = line.strip_suffix('+') {
|
||||
self.output.push_str(stripped);
|
||||
self.output.push('\\');
|
||||
} else {
|
||||
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)> {
|
||||
const HYPHYEN_MARKER: &'static str = "- ";
|
||||
if let Some(text) = line.strip_prefix(HYPHYEN_MARKER) {
|
||||
const HYPHEN_MARKER: &str = "- ";
|
||||
if let Some(text) = line.strip_prefix(HYPHEN_MARKER) {
|
||||
Some((ListMarker::Hyphen, text))
|
||||
} else if let Some((count, text)) = strip_prefix_symbol(line, '*') {
|
||||
Some((ListMarker::Asterisk(count), text))
|
||||
|
Loading…
Reference in New Issue
Block a user