1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Improve LoadUnitConfig to handle invalid or duplicate units (#23736)

The old code just parses an invalid key to `TypeInvalid` and uses it as
normal, and duplicate keys will be kept.

So this PR will ignore invalid key and log warning and also deduplicate
valid units.
This commit is contained in:
Jason Song
2023-04-03 16:42:38 +08:00
committed by GitHub
parent ca905b82df
commit d67e40684f
3 changed files with 77 additions and 17 deletions

View File

@@ -135,7 +135,7 @@ func GetTeam(ctx *context.APIContext) {
}
func attachTeamUnits(team *organization.Team, units []string) {
unitTypes := unit_model.FindUnitTypes(units...)
unitTypes, _ := unit_model.FindUnitTypes(units...)
team.Units = make([]*organization.TeamUnit, 0, len(units))
for _, tp := range unitTypes {
team.Units = append(team.Units, &organization.TeamUnit{