Skip to content

Commit

Permalink
Generate list of author links
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Aug 23, 2022
1 parent f1c8454 commit d5179cf
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions tools/automator/src/announcement.rs
Original file line number Diff line number Diff line change
@@ -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<Utc>,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -125,7 +150,8 @@ Improvements that are relevant to developers working on Fornjot itself.
**TASK: Write.**
{pull_request_links}\
{pull_request_links}
{author_links}\
"
)?;

Expand Down

0 comments on commit d5179cf

Please sign in to comment.