diff --git a/pkg/notes/document/document.go b/pkg/notes/document/document.go index cfa4318360a3..fc3bf6d460af 100644 --- a/pkg/notes/document/document.go +++ b/pkg/notes/document/document.go @@ -217,11 +217,6 @@ func New( for _, pr := range releaseNotes.History() { note := releaseNotes.Get(pr) - if note.DoNotPublish { - logrus.Debugf("skipping PR %d as (marked to not be published)", pr) - continue - } - if _, hasCVE := note.DataFields["cve"]; hasCVE { logrus.Infof("Release note for PR #%d has CVE vulnerability info", note.PrNumber) @@ -240,6 +235,11 @@ func New( doc.CVEList = append(doc.CVEList, newcve) } + if note.DoNotPublish { + logrus.Debugf("skipping PR %d as (marked to not be published)", pr) + continue + } + // TODO: Refactor the logic here and add testing. if note.DuplicateKind { kind := mapKind(highestPriorityKind(note.Kinds)) diff --git a/pkg/notes/notes.go b/pkg/notes/notes.go index 438edcd2ecf4..ca8572ad8021 100644 --- a/pkg/notes/notes.go +++ b/pkg/notes/notes.go @@ -269,11 +269,45 @@ func (g *Gatherer) ListReleaseNotes() (*ReleaseNotes, error) { return nil, errors.Wrap(err, "listing commits") } - results, err := g.gatherNotes(commits) + // Get the PRs into a temporary results set + resultsTemp, err := g.gatherNotes(commits) if err != nil { return nil, errors.Wrap(err, "gathering notes") } + // Cycle the results and add the complete notes, as well as those that + // have a map associated with it + results := []*Result{} + logrus.Info("Checking PRs for mapped data") + for _, res := range resultsTemp { + // If the PR has no release note, check if we have to add it + if MatchesExcludeFilter(*res.pullRequest.Body) { + for _, provider := range mapProviders { + noteMaps, err := provider.GetMapsForPR(res.pullRequest.GetNumber()) + if err != nil { + return nil, errors.Wrapf( + err, "checking if a map exists for PR %d", res.pullRequest.GetNumber(), + ) + } + if len(noteMaps) != 0 { + logrus.Infof( + "Artificially adding pr #%d because a map for it was found", + res.pullRequest.GetNumber(), + ) + results = append(results, res) + } + } + logrus.Debugf( + "Skipping PR #%d because it contains no release note", + res.pullRequest.GetNumber(), + ) + continue + } else { + // Append the note as it is + results = append(results, res) + } + } + dedupeCache := map[string]struct{}{} notes := NewReleaseNotes() for _, result := range results { @@ -311,7 +345,6 @@ func (g *Gatherer) ListReleaseNotes() (*ReleaseNotes, error) { dedupeCache[note.Text] = struct{}{} } } - return notes, nil } @@ -676,14 +709,6 @@ func (g *Gatherer) notesForCommit(commit *gogithub.RepositoryCommit) (*Result, e "Got PR #%d for commit: %s", pr.GetNumber(), commit.GetSHA(), ) - if MatchesExcludeFilter(prBody) { - logrus.Debugf( - "Skipping PR #%d because it contains no release note", - pr.GetNumber(), - ) - continue - } - if MatchesIncludeFilter(prBody) { res := &Result{commit: commit, pullRequest: pr} logrus.Infof("PR #%d seems to contain a release note", pr.GetNumber())