From 7a04c11d17ceb149861c3c892514d8856701dbbb Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 8 Nov 2022 11:19:39 +0100 Subject: [PATCH] Fix release announcements including older PRs Previously, pull requests merged before the most recent release were still included, if they were updated after the most recent release. --- tools/automator/src/pull_requests.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/automator/src/pull_requests.rs b/tools/automator/src/pull_requests.rs index 102174632..fa8b08a1a 100644 --- a/tools/automator/src/pull_requests.rs +++ b/tools/automator/src/pull_requests.rs @@ -20,7 +20,7 @@ impl PullRequestsSinceLastRelease { let mut pull_requests = BTreeMap::new(); let mut page = 1u32; - let version_of_last_release = 'outer: loop { + let (version_of_last_release, time_of_last_release) = 'outer: loop { const MAX_RESULTS_PER_PAGE: u8 = 100; println!("Fetching page {}...", page); @@ -60,7 +60,12 @@ impl PullRequestsSinceLastRelease { ) })?; - break 'outer version; + let time = + pull_request.merged_at.ok_or_else(|| { + anyhow!("Release PR is missing merge time") + })?; + + break 'outer (version, time); } } } @@ -99,6 +104,10 @@ impl PullRequestsSinceLastRelease { } }; + pull_requests.retain(|_, pull_request| { + pull_request.merged_at > time_of_last_release + }); + Ok(Self { pull_requests, version_of_last_release,