Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
IceSentry committed Jan 29, 2023
1 parent 6ac79c4 commit 19a2fd7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
12 changes: 3 additions & 9 deletions generate-migration-guide/src/github_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl GithubClient {
) -> anyhow::Result<Vec<GithubCommitResponse>> {
let request = self
.get("https://github.com/gitapi/repos/bevyengine/bevy/commits")
.query("since", &format!("{}T00:00:00Z", since))
.query("since", &format!("{since}T00:00:00Z"))
.query("per_page", "100")
.query("page", &page.to_string())
.query("sha", sha);
Expand All @@ -164,7 +164,7 @@ impl GithubClient {
}
let request = self
.get("https://github.com/gitapi/search/users")
.query("q", &format!("{email}"));
.query("q", email);
let response = request.call()?.into_json()?;
self.user_cache.insert(email.to_string(), response);
Ok(self.user_cache.get(email).unwrap().clone())
Expand Down Expand Up @@ -217,7 +217,7 @@ impl GithubClient {
) -> anyhow::Result<Vec<GithubIssuesResponse>> {
let mut request = self
.get("https://github.com/gitapi/repos/bevyengine/bevy/issues")
.query("since", &format!("{}T00:00:00Z", date))
.query("since", &format!("{date}T00:00:00Z"))
.query("state", "closed")
.query("base", "main")
.query("per_page", "100")
Expand All @@ -233,10 +233,4 @@ impl GithubClient {
.cloned()
.collect())
}

pub fn generate_release_note(&self) -> anyhow::Result<String> {
let request =
self.get("https://github.com/gitapi/repos/bevyengine/bevy/releases/generate-notes");
Ok(request.call()?.into_json()?)
}
}
28 changes: 13 additions & 15 deletions generate-migration-guide/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ fn generate_release_note(
});
}
Err(err) => {
println!("Error while getting user by email: {}", err);
println!("Error while getting user by email: {err}");
println!("sleeping to avoid being rate limited");
std::thread::sleep(std::time::Duration::from_secs(10));
println!("sleeping to avoid being rate limited");
Expand Down Expand Up @@ -206,7 +206,7 @@ fn generate_release_note(
writeln!(&mut output, "## Contributors\n")?;
writeln!(&mut output, "A huge thanks to the {} contributors that made this release (and associated docs) possible! In random order:\n", authors.len())?;
for author in &authors {
writeln!(&mut output, "- @{}", author)?;
writeln!(&mut output, "- @{author}")?;
}
writeln!(&mut output)?;
writeln!(&mut output, "### Co-Authors")?;
Expand All @@ -219,22 +219,22 @@ fn generate_release_note(
writeln!(&mut output)?;

for co_author in &co_authors {
writeln!(&mut output, "- {}", co_author)?;
writeln!(&mut output, "- {co_author}")?;
}
writeln!(&mut output)?;

writeln!(&mut output, "## Full Changelog")?;

for (area, prs) in &areas {
writeln!(&mut output)?;
writeln!(&mut output, "## {}", area)?;
writeln!(&mut output, "## {area}")?;
writeln!(&mut output)?;

for pr_number in prs {
let Some(pr_title) = pr_map.get(pr_number) else {
continue;
};
writeln!(&mut output, "- [{}][{}]", pr_title, pr_number)?;
writeln!(&mut output, "- [{pr_title}][{pr_number}]")?;
}
}

Expand All @@ -243,8 +243,7 @@ fn generate_release_note(
for pr in pr_map.keys() {
writeln!(
&mut output,
"[{}]: https://github.com/bevyengine/bevy/pull/{}",
pr, pr
"[{pr}]: https://github.com/bevyengine/bevy/pull/{pr}"
)?;
}

Expand All @@ -266,19 +265,18 @@ fn generate_migration_guide(
write!(
&mut output,
r#"+++
title = "{}"
weight = {}
title = "{title}"
weight = {weight}
sort_by = "weight"
template = "book-section.html"
page_template = "book-section.html"
insert_anchor_links = "right"
[extra]
long_title = "Migration Guide: {}"
long_title = "Migration Guide: {title}"
+++
Bevy relies heavily on improvements in the Rust language and compiler.
As a result, the Minimum Supported Rust Version (MSRV) is "the latest stable release" of Rust."#,
title, weight, title
As a result, the Minimum Supported Rust Version (MSRV) is "the latest stable release" of Rust."#
)?;
writeln!(&mut output)?;

Expand All @@ -289,7 +287,7 @@ As a result, the Minimum Supported Rust Version (MSRV) is "the latest stable rel
.replace("[Merged by Bors] - ", "")
.trim()
.to_string();
println!("# {}", pr_title);
println!("# {pr_title}");

// Write title for the PR with correct heading and github url
writeln!(
Expand Down Expand Up @@ -349,7 +347,7 @@ fn write_markdown_section(
if !section_found {
// Someone didn't write a migration guide 😢
writeln!(output, "\n<!-- TODO -->")?;
println!("\x1b[93m{} not found!\x1b[0m", section_header);
println!("\x1b[93m{section_header} not found!\x1b[0m");
Ok(false)
} else {
Ok(true)
Expand Down Expand Up @@ -381,7 +379,7 @@ fn write_markdown_event(event: &Event, output: &mut String) -> anyhow::Result<()
Event::Text(text) => write!(output, "{text}")?,
Event::Code(text) => write!(output, "`{text}`")?,
Event::SoftBreak => writeln!(output)?,
_ => println!("unknown event {:?}", event),
_ => println!("unknown event {event:?}"),
};
Ok(())
}

0 comments on commit 19a2fd7

Please sign in to comment.