From 26cdea3487c47d4d29b2c457aa4acdbd38f9e8d1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 8 Nov 2022 11:00:05 +0100 Subject: [PATCH 1/4] Fix contributors only being thanked once Contributors were only thanked for one pull request per release announcement. --- tools/automator/src/announcement.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/automator/src/announcement.rs b/tools/automator/src/announcement.rs index 9162265ea..9bd159394 100644 --- a/tools/automator/src/announcement.rs +++ b/tools/automator/src/announcement.rs @@ -97,12 +97,9 @@ async fn generate_announcement( author, } = pull_request; - let author = if authors.contains(&author.name) - || author_blacklist.contains(author.name.as_str()) - { + let author = if author_blacklist.contains(author.name.as_str()) { None } else { - authors.insert(author.name.clone()); Some(author) }; @@ -118,8 +115,12 @@ async fn generate_announcement( pull_request_links.push_str(&link); if let Some(Author { name, profile }) = author { - let author_link = format!("[@{name}]: {profile}\n"); - author_links.push_str(&author_link); + if !authors.contains(&name) { + let author_link = format!("[@{name}]: {profile}\n"); + author_links.push_str(&author_link); + + authors.insert(name.clone()); + } } } From dc244d5fecbcc82e9fe6158c56eab15f2e41a63c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 8 Nov 2022 11:07:21 +0100 Subject: [PATCH 2/4] Include merge date in `PullRequest` --- tools/automator/src/announcement.rs | 1 + tools/automator/src/pull_requests.rs | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/automator/src/announcement.rs b/tools/automator/src/announcement.rs index 9bd159394..3c11266ac 100644 --- a/tools/automator/src/announcement.rs +++ b/tools/automator/src/announcement.rs @@ -95,6 +95,7 @@ async fn generate_announcement( title, url, author, + .. } = pull_request; let author = if author_blacklist.contains(author.name.as_str()) { diff --git a/tools/automator/src/pull_requests.rs b/tools/automator/src/pull_requests.rs index 61a885cde..582c5299a 100644 --- a/tools/automator/src/pull_requests.rs +++ b/tools/automator/src/pull_requests.rs @@ -2,6 +2,7 @@ use std::collections::BTreeMap; use anyhow::anyhow; use autolib::find_version_in_str; +use chrono::{DateTime, Utc}; use octocrab::{ models::pulls::PullRequest as OctoPullRequest, params::{pulls::Sort, Direction, State}, @@ -64,10 +65,10 @@ impl PullRequestsSinceLastRelease { } } - if pull_request.merged_at.is_none() { + let Some(merged_at) = pull_request.merged_at else { // If it wasn't merged, we're not interested. continue; - } + }; let number = pull_request.number; let title = pull_request @@ -85,6 +86,7 @@ impl PullRequestsSinceLastRelease { title, url, author, + merged_at, }; pull_requests.insert(pull_request.number, pull_request); @@ -109,6 +111,7 @@ pub struct PullRequest { pub title: String, pub url: Url, pub author: Author, + pub merged_at: DateTime, } pub struct Author { From 3922d3d53716575d5637e7b55f687af828079bd8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 8 Nov 2022 11:09:05 +0100 Subject: [PATCH 3/4] Improve formatting --- tools/automator/src/pull_requests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/automator/src/pull_requests.rs b/tools/automator/src/pull_requests.rs index 582c5299a..102174632 100644 --- a/tools/automator/src/pull_requests.rs +++ b/tools/automator/src/pull_requests.rs @@ -51,8 +51,8 @@ impl PullRequestsSinceLastRelease { pull_request.title.ok_or_else(|| { anyhow!("Release PR is missing title") })?; - let version = find_version_in_str(&title)?; + let version = find_version_in_str(&title)?; let version = version.ok_or_else(|| { anyhow!( "Pull request title contains no version:\ From 7a04c11d17ceb149861c3c892514d8856701dbbb Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 8 Nov 2022 11:19:39 +0100 Subject: [PATCH 4/4] 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,