diff options
author | Pietro Albini <pietro@pietroalbini.org> | 2019-03-30 11:36:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-30 11:36:31 +0100 |
commit | 6aa6d5abcd02ce5cd36606bc458372e7c65a0f8b (patch) | |
tree | 135195fcead2412a93b1d2951675d89083ecaefa /src/validate.rs | |
parent | a52b45a0a7e3d11132ab701b983a4aad2c4fb065 (diff) | |
parent | b9db45fe621b57829556d35b132549a271dfe253 (diff) |
Merge pull request #50 from rust-lang/rfcbot
Add rfcbot data to the Team API
Diffstat (limited to 'src/validate.rs')
-rw-r--r-- | src/validate.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/validate.rs b/src/validate.rs index 90881fe..21570d2 100644 --- a/src/validate.rs +++ b/src/validate.rs @@ -18,6 +18,7 @@ static CHECKS: &[fn(&Data, &mut Vec<String>)] = &[ validate_discord_name, validate_duplicate_permissions, validate_permissions, + validate_rfcbot_labels, ]; pub(crate) fn validate(data: &Data) -> Result<(), Error> { @@ -284,6 +285,19 @@ fn validate_permissions(data: &Data, errors: &mut Vec<String>) { }); } +/// Ensure there are no duplicate rfcbot labels +fn validate_rfcbot_labels(data: &Data, errors: &mut Vec<String>) { + let mut labels = HashSet::new(); + wrapper(data.teams(), errors, move |team, errors| { + if let Some(rfcbot) = team.rfcbot_data() { + if !labels.insert(rfcbot.label.clone()) { + errors.push(format!("duplicate rfcbot label: {}", rfcbot.label)); + } + } + Ok(()) + }); +} + fn wrapper<T, I, F>(iter: I, errors: &mut Vec<String>, mut func: F) where I: Iterator<Item = T>, |