diff --git a/Services/AutoMaintainer/definition.go b/Services/AutoMaintainer/definition.go index 56c51424e50e0bf06fce3be2e1430d88ccc2364c..64f1b88a2267e22f50a8effa91f1675734ca4e28 100644 --- a/Services/AutoMaintainer/definition.go +++ b/Services/AutoMaintainer/definition.go @@ -159,6 +159,7 @@ func (s Service) Process(payload *gitlab.MergeEvent, log *zerolog.Logger) { } // List of maintainers that have been found + // This is a "set" maintainersFound := make(map[string]bool) for _, diff := range diffs { @@ -187,7 +188,9 @@ func (s Service) Process(payload *gitlab.MergeEvent, log *zerolog.Logger) { continue } for _, maintainer := range maintainerSlice { - // Add the maintainerEmail we found from the APKBUILD into the map + // Add the maintainerEmail we found from the APKBUILD + // We add all of them (with and without tags), since we + // are not sure which might have the user used! maintainersFound[maintainer.GetEmail()] = true } } @@ -200,20 +203,22 @@ func (s Service) Process(payload *gitlab.MergeEvent, log *zerolog.Logger) { return } - if len(maintainersFound) > 1 { - sLog.Warn().Msg("too many maintainers found to assign") - return - } - - for k := range maintainersFound { + assigned := false + for email := range maintainersFound { // Transform the email into the user - maintainerUser, err := hasUser(s.gitlabClient, k) + maintainerUser, err := hasUser(s.gitlabClient, email) if err != nil { - sLog.Error(). - Err(err). - Msg("failed to convert APKBUILD maintainer to GitLab user") + sLog.Info(). + Str("email", email). + Msg("No user associated with this email") + continue + } - return + if assigned { + sLog.Warn(). + Str("email", email). + Msg("Maintainer already assigned, but new one found") + continue } // Try to get Username via its ID @@ -237,6 +242,7 @@ func (s Service) Process(payload *gitlab.MergeEvent, log *zerolog.Logger) { } sLog.Info().Str("user", maintainerUser.Username).Msg("assigning") + assigned = true if !s.dryRun { _, _, err = s.gitlabClient.MergeRequests.UpdateMergeRequest(