From d5179cf45457af26e700d417dd2efbc04400f757 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 23 Aug 2022 11:35:19 +0200 Subject: [PATCH] Generate list of author links --- tools/automator/src/announcement.rs | 34 +++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/tools/automator/src/announcement.rs b/tools/automator/src/announcement.rs index ce1a74ce4..d0805ad7c 100644 --- a/tools/automator/src/announcement.rs +++ b/tools/automator/src/announcement.rs @@ -1,13 +1,14 @@ -use std::{fmt::Write, path::PathBuf}; +use std::{collections::HashSet, fmt::Write, path::PathBuf}; use anyhow::Context; use chrono::{Date, Datelike, Utc}; +use map_macro::set; use tokio::{ fs::{self, File}, io::AsyncWriteExt, }; -use crate::pull_requests::PullRequest; +use crate::pull_requests::{Author, PullRequest}; pub async fn create_release_announcement( last_release_date: Date, @@ -52,17 +53,41 @@ async fn generate_announcement( ) -> anyhow::Result<()> { let mut pull_request_list = String::new(); let mut pull_request_links = String::new(); + let mut author_links = String::new(); + + let author_blacklist = set! { + "hannobraun", + "dependabot[bot]" + }; + let mut authors = HashSet::new(); for pull_request in pull_requests { let PullRequest { - number, title, url, .. + number, + title, + url, + author, } = pull_request; + let author = if authors.contains(&author.name) + || author_blacklist.contains(author.name.as_str()) + { + None + } else { + authors.insert(author.name.clone()); + Some(author) + }; + let item = format!("- {title} ([#{number}])\n"); pull_request_list.push_str(&item); let link = format!("[#{number}]: {url}\n"); 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); + } } let mut buf = String::new(); @@ -125,7 +150,8 @@ Improvements that are relevant to developers working on Fornjot itself. **TASK: Write.** -{pull_request_links}\ +{pull_request_links} +{author_links}\ " )?;