fix: 🐛 attempt to fix the Duplication of PRs in Rrelease Draft
This commit is contained in:
parent
56650ff20f
commit
1fbb0eba98
|
@ -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 {
|
|
||||||
if prHasLabel(prs, category.Labels) {
|
|
||||||
// Correctly append each PR in the slice
|
|
||||||
for _, pr := range prs {
|
for _, pr := range prs {
|
||||||
|
categorized := false
|
||||||
|
for _, category := range cfg.Categories {
|
||||||
|
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,8 +167,7 @@ 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 {
|
||||||
|
@ -168,6 +175,5 @@ func prHasLabel(prs []*gitea.PullRequest, labels []string) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue