Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for removing users' names upon request #58

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use reviewers::Reviewers;

mod config;
mod error;
mod removed;
mod reviewers;
mod site;

Expand Down
35 changes: 35 additions & 0 deletions src/removed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use std::collections::HashSet;
use std::iter::FromIterator;

use mailmap::Author;

lazy_static::lazy_static! {
static ref REMOVED: HashSet<mailmap::Author> = HashSet::from_iter([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: probably add a comment linking to the teams repo PR so this can be found again when someone inevitably asks what this is for in a couple years

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oddly enough I intended to do this and totally forgot.

Author {
name: "Jonas Schievink".to_string(),
email: "[email protected]".to_string()
},
Author {
name: "Jonas Schievink".to_string(),
email: "[email protected]".to_string()
},
Author {
name: "Jonas Schievink".to_string(),
email: "[email protected]".to_string()
},
Author {
name: "Jonas Schievink".to_string(),
email: "[email protected]".to_string()
}
]);
}

pub(crate) trait Removed {
fn is_removed(&self) -> bool;
}

impl Removed for Author {
fn is_removed(&self) -> bool {
REMOVED.contains(self)
}
}
7 changes: 6 additions & 1 deletion src/site.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::removed::Removed;
use crate::{AuthorMap, VersionTag};
use handlebars::Handlebars;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -146,7 +147,11 @@ fn author_map_to_scores(map: &AuthorMap) -> Vec<Entry> {
.iter()
.map(|(author, commits)| Entry {
rank: 0,
author: author.name.clone(),
author: if author.is_removed() {
"[removed]".to_string()
} else {
author.name.clone()
},
commits: commits,
})
.collect::<Vec<_>>();
Expand Down