package main

import (
	"slices"

	"src.opensuse.org/autogits/common"
)

type Reviewers struct {
	Prj []string
	Pkg []string
}

func ParseReviewers(input []string) *Reviewers {
	r := &Reviewers{}
	for _, reviewer := range input {
		switch reviewer[0] {
		case '*':
			r.Prj = append(r.Prj, reviewer[1:])
			r.Pkg = append(r.Pkg, reviewer[1:])
		case '-':
			r.Prj = append(r.Prj, reviewer[1:])
		case '+':
			r.Pkg = append(r.Pkg, reviewer[1:])
		default:
			r.Pkg = append(r.Pkg, reviewer)
		}
	}

	if !slices.Contains(r.Prj, common.Bot_BuildReview) {
		r.Prj = append(r.Prj, common.Bot_BuildReview)
	}

	return r
}
