Skip to content

Commit

Permalink
Fix some bugs in the script
Browse files Browse the repository at this point in the history
* Deprecation warnings
* Case-insensitive section matching
* Point at intended referenced PR/issue (helps debug why we aren't
  correctly finding it)
  • Loading branch information
Mark-Simulacrum committed Jan 20, 2025
1 parent 700ccc2 commit c8409f4
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ fn main() {
let version = args
.next()
.expect("A version number (xx.yy.zz) for the Rust release is required.");
let today = Utc::now().date();
let today = Utc::now().date_naive();

// A known rust release date. (1.42.0)
let mut end = Utc.ymd(2020, 3, 12);
let mut end = Utc
.with_ymd_and_hms(2020, 3, 12, 0, 0, 0)
.single()
.unwrap()
.date_naive();
let six_weeks = Duration::weeks(6);

// Get the most recent rust release date.
Expand Down Expand Up @@ -126,17 +130,20 @@ fn main() {
}

eprintln!(
"Did not use {:?} from {} <{}>",
"Did not use {:?} from {} <{}> (intended to provide relnotes for: {:?})",
section,
issue.raw["title"].as_str().unwrap(),
issue.raw["url"].as_str().unwrap()
issue.raw["url"].as_str().unwrap(),
issues
.iter()
.find(|i| i["number"].as_u64().unwrap() == issue.for_number)
);
}
}

let relnotes = ReleaseNotes {
version,
date: (end + six_weeks).naive_utc(),
date: end + six_weeks,

language_relnotes,
compiler_relnotes,
Expand Down Expand Up @@ -282,6 +289,7 @@ struct TrackingIssues {

#[derive(Debug)]
struct TrackingIssue {
for_number: u64,
raw: json::Value,
// Section name -> (used, lines)
sections: HashMap<String, (bool, Vec<String>)>,
Expand Down Expand Up @@ -331,6 +339,7 @@ impl TrackingIssues {
tracking_issues.insert(
for_number,
TrackingIssue {
for_number,
raw: o.clone(),
sections,
},
Expand Down Expand Up @@ -362,7 +371,10 @@ fn map_to_line_items<'a>(
}

for (section, (used, lines)) in issue.sections.iter_mut() {
if let Some(contents) = by_section.get_mut(section.as_str()) {
if let Some((_, contents)) = by_section
.iter_mut()
.find(|(s, _)| s.eq_ignore_ascii_case(section))
{
*used = true;
for line in lines.iter() {
contents.push_str(line);
Expand Down

0 comments on commit c8409f4

Please sign in to comment.