Fix duplicated contributions in changelog tool

This commit is contained in:
Héctor Ramón Jiménez 2024-09-18 02:22:52 +02:00
parent 4c9223c1cb
commit ddcf9262f5
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -2,6 +2,7 @@ use serde::Deserialize;
use tokio::fs;
use tokio::process;
use std::collections::BTreeSet;
use std::env;
use std::fmt;
use std::io;
@ -261,7 +262,7 @@ impl fmt::Display for Category {
}
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Contribution {
pub id: u64,
}
@ -281,7 +282,7 @@ impl Contribution {
let log = String::from_utf8_lossy(&output.stdout);
Ok(log
let mut contributions: Vec<_> = log
.lines()
.filter(|title| !title.is_empty())
.filter_map(|title| {
@ -292,7 +293,12 @@ impl Contribution {
id: pull_request.parse().ok()?,
})
})
.collect())
.collect();
let mut unique = BTreeSet::from_iter(contributions.clone());
contributions.retain_mut(|contribution| unique.remove(contribution));
Ok(contributions)
}
}