Skip to content

Commit 5beeee1

Browse files
committed
chore: add check duplicate to the team members
1 parent bc36284 commit 5beeee1

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

src/validate.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,35 +220,37 @@ fn validate_team_leads(data: &Data, errors: &mut Vec<String>) {
220220
});
221221
}
222222

223-
/// Ensure team members are people and don't contain duplicates
223+
/// Ensure team members are unique and exist
224224
fn validate_team_members(data: &Data, errors: &mut Vec<String>) {
225225
wrapper(data.teams(), errors, |team, errors| {
226-
let mut seen = std::collections::HashSet::new();
227-
wrapper(team.members(data)?.iter(), errors, |member, _| {
228-
// Check if member exists
229-
if data.person(member).is_none() {
226+
// Check for duplicate members in explicit_members
227+
let mut seen = HashSet::new();
228+
for member in team.explicit_members() {
229+
if !seen.insert(&member.github) {
230230
bail!(
231-
"person {} is member of team {} but doesn't exist",
232-
member,
231+
"person `{}` is duplicated in team `{}`",
232+
member.github,
233233
team.name()
234234
);
235235
}
236+
}
236237

237-
// Check for duplicates
238-
if !seen.insert(member) {
238+
// Ensure members are real people
239+
wrapper(team.members(data)?.iter(), errors, |member, _| {
240+
if data.person(member).is_none() {
239241
bail!(
240-
"person {} is listed multiple times in team {}",
242+
"person `{}` is member of team `{}` but doesn't exist",
241243
member,
242244
team.name()
243245
);
244246
}
245-
246247
Ok(())
247248
});
248249
Ok(())
249250
});
250251
}
251252

253+
252254
/// Alumni team must consist only of automatically populated alumni from the other teams
253255
fn validate_alumni(data: &Data, errors: &mut Vec<String>) {
254256
let Some(alumni_team) = data.team("alumni") else {

tests/bless.sh

100755100644
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#!/bin/bash
2-
3-
set -euo pipefail
4-
IFS=$'\n\t'
5-
6-
cd "$(dirname "$0")"
7-
if [[ -d static-api/_output ]]; then
8-
rm -rf static-api/_expected
9-
cp -r static-api/_output static-api/_expected
10-
else
11-
echo "didn't bless static-api as there is no output to bless"
12-
fi
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
IFS=$'\n\t'
5+
6+
cd "$(dirname "$0")"
7+
if [[ -d static-api/_output ]]; then
8+
rm -rf static-api/_expected
9+
cp -r static-api/_output static-api/_expected
10+
else
11+
echo "didn't bless static-api as there is no output to bless"
12+
fi

0 commit comments

Comments
 (0)