Skip to content

Commit d482fcb

Browse files
committed
improve repo validation error message
1 parent 27adb90 commit d482fcb

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

Diff for: src/data.rs

+7
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ impl Data {
210210
}
211211
result
212212
}
213+
214+
pub(crate) fn is_team_archived(&self, team_name: &str, org: &str) -> bool {
215+
self.archived_teams()
216+
.filter_map(|team| team.github_teams(self).ok())
217+
.flatten()
218+
.any(|github_team| github_team.name == team_name && github_team.org == org)
219+
}
213220
}
214221

215222
fn load_file<T: DeserializeOwned>(path: &Path) -> Result<T, Error> {

Diff for: src/validate.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -868,20 +868,25 @@ fn validate_repos(data: &Data, errors: &mut Vec<String>) {
868868
}
869869
for team_name in repo.access.teams.keys() {
870870
if !github_teams.contains(&(repo.org.clone(), team_name.clone())) {
871+
let error_reason = if data.is_team_archived(team_name, &repo.org) {
872+
"is archived. Please remove the team access from the `[access.teams]` section of the repo"
873+
} else {
874+
"is not present in the `/teams/` folder"
875+
};
876+
871877
bail!(
872-
"access for {}/{} is invalid: '{}' is not configured as a GitHub team for the '{}' org",
873-
repo.org,
874-
repo.name,
875-
team_name,
876-
repo.org
877-
)
878+
"Access for the repo {}/{} is invalid: the team '{}/{team_name}' {error_reason}.",
879+
repo.org,
880+
repo.name,
881+
repo.org,
882+
);
878883
}
879884
}
880885

881886
for name in repo.access.individuals.keys() {
882887
if data.person(name).is_none() {
883888
bail!(
884-
"access for {}/{} is invalid: '{}' is not the name of a person in the team repo",
889+
"Access for the repo {}/{} is invalid: '{}' is not the name of a person in the team repo",
885890
repo.org,
886891
repo.name,
887892
name

0 commit comments

Comments
 (0)