@@ -37,6 +37,7 @@ import (
37
37
38
38
gogithub "github.com/google/go-github/v58/github"
39
39
"github.com/nozzle/throttler"
40
+ "github.com/sergi/go-diff/diffmatchpatch"
40
41
"github.com/sirupsen/logrus"
41
42
"golang.org/x/text/cases"
42
43
"golang.org/x/text/language"
@@ -139,6 +140,9 @@ type ReleaseNote struct {
139
140
140
141
// IsMapped is set if the note got modified from a map
141
142
IsMapped bool `json:"is_mapped,omitempty"`
143
+
144
+ // PRBody is the full PR body of the release note
145
+ PRBody string `json:"pr_body,omitempty"`
142
146
}
143
147
144
148
type Documentation struct {
@@ -518,6 +522,7 @@ func (g *Gatherer) ReleaseNoteFromCommit(result *Result) (*ReleaseNote, error) {
518
522
DuplicateKind : isDuplicateKind ,
519
523
ActionRequired : labelExactMatch (pr , "release-note-action-required" ),
520
524
DoNotPublish : labelExactMatch (pr , "release-note-none" ),
525
+ PRBody : prBody ,
521
526
}, nil
522
527
}
523
528
@@ -757,6 +762,7 @@ func (g *Gatherer) ReleaseNoteForPullRequest(prNr int) (*ReleaseNote, error) {
757
762
ActionRequired : false ,
758
763
DoNotPublish : doNotPublish ,
759
764
DataFields : map [string ]ReleaseNotesDataField {},
765
+ PRBody : prBody ,
760
766
}
761
767
762
768
if s != "" {
@@ -1151,6 +1157,14 @@ func (rn *ReleaseNote) ApplyMap(noteMap *ReleaseNotesMap, markdownLinks bool) er
1151
1157
}).Debugf ("Applying map to note" )
1152
1158
rn .IsMapped = true
1153
1159
1160
+ if noteMap .PRBody != nil && rn .PRBody != "" && rn .PRBody != * noteMap .PRBody {
1161
+ logrus .Warnf ("Original PR body of release note mapping changed for PR: #%d" , rn .PrNumber )
1162
+
1163
+ dmp := diffmatchpatch .New ()
1164
+ diffs := dmp .DiffMain (rn .PRBody , * noteMap .PRBody , false )
1165
+ logrus .Warnf ("The diff between actual release note body and mapped one is:\n %s" , dmp .DiffPrettyText (diffs ))
1166
+ }
1167
+
1154
1168
reRenderMarkdown := false
1155
1169
if noteMap .ReleaseNote .Author != nil {
1156
1170
rn .Author = * noteMap .ReleaseNote .Author
@@ -1231,6 +1245,7 @@ func (rn *ReleaseNote) ToNoteMap() (string, error) {
1231
1245
noteMap .ReleaseNote .Feature = & rn .Feature
1232
1246
noteMap .ReleaseNote .ActionRequired = & rn .ActionRequired
1233
1247
noteMap .ReleaseNote .DoNotPublish = & rn .DoNotPublish
1248
+ noteMap .PRBody = & rn .PRBody
1234
1249
1235
1250
yamlCode , err := yaml .Marshal (& noteMap )
1236
1251
if err != nil {
0 commit comments