fix/1/stop-duplicate-prs-in-release-draft #2

Merged
florian merged 4 commits from fix/1/stop-duplicate-prs-in-release-draft into main 2024-01-15 10:34:07 +01:00
1 changed files with 18 additions and 12 deletions
Showing only changes of commit 1fbb0eba98 - Show all commits

View File

@ -53,13 +53,21 @@ func updateOrCreateDraftRelease(a *Action, cfg *config.RepoConfig) (*gitea.Relea
categorizedPRs := make(map[string][]*gitea.PullRequest) categorizedPRs := make(map[string][]*gitea.PullRequest)
for _, prs := range *changelog { for _, prs := range *changelog {
for _, category := range cfg.Categories { for _, pr := range prs {
if prHasLabel(prs, category.Labels) { categorized := false
// Correctly append each PR in the slice for _, category := range cfg.Categories {
for _, pr := range prs { if !categorized && prHasLabel(pr, category.Labels) {
categorizedPRs[category.Title] = append(categorizedPRs[category.Title], pr) categorizedPRs[category.Title] = append(categorizedPRs[category.Title], pr)
categorized = true
break // Break out of the category loop
} }
break }
if !categorized {
// Add to a default category if not categorized
categorizedPRs["Other Changes"] = append(categorizedPRs["Other Changes"], pr)
}
if categorized {
break // Break out of the PR loop once categorized
} }
} }
} }
@ -159,13 +167,11 @@ func (a *Action) Run() error {
return nil return nil
} }
func prHasLabel(prs []*gitea.PullRequest, labels []string) bool { func prHasLabel(pr *gitea.PullRequest, labels []string) bool {
for _, pr := range prs { for _, prLabel := range pr.Labels {
for _, prLabel := range pr.Labels { for _, label := range labels {
for _, label := range labels { if prLabel.Name == label {
if prLabel.Name == label { return true
return true
}
} }
} }
} }