diff --git a/src/data.rs b/src/data.rs index b305daa3f..078a85d1d 100644 --- a/src/data.rs +++ b/src/data.rs @@ -210,6 +210,13 @@ impl Data { } result } + + pub(crate) fn is_team_archived(&self, team_name: &str, org: &str) -> bool { + self.archived_teams() + .filter_map(|team| team.github_teams(self).ok()) + .flatten() + .any(|github_team| github_team.name == team_name && github_team.org == org) + } } fn load_file(path: &Path) -> Result { diff --git a/src/validate.rs b/src/validate.rs index 7f4ef4609..eb6a26490 100644 --- a/src/validate.rs +++ b/src/validate.rs @@ -868,20 +868,25 @@ fn validate_repos(data: &Data, errors: &mut Vec) { } for team_name in repo.access.teams.keys() { if !github_teams.contains(&(repo.org.clone(), team_name.clone())) { + let error_reason = if data.is_team_archived(team_name, &repo.org) { + "is archived. Please remove the team access from the `[access.teams]` section of the repo" + } else { + "is not present in the `/teams/` folder" + }; + bail!( - "access for {}/{} is invalid: '{}' is not configured as a GitHub team for the '{}' org", - repo.org, - repo.name, - team_name, - repo.org - ) + "Access for the repo {}/{} is invalid: the team '{}/{team_name}' {error_reason}.", + repo.org, + repo.name, + repo.org, + ); } } for name in repo.access.individuals.keys() { if data.person(name).is_none() { bail!( - "access for {}/{} is invalid: '{}' is not the name of a person in the team repo", + "Access for the repo {}/{} is invalid: '{}' is not the name of a person in the team repo", repo.org, repo.name, name