Skip to content

append the release note if there is no release note block - #803

Open
pacoxu wants to merge 1 commit into
kubernetes-sigs:mainfrom
pacoxu:append-release-note
Open

append the release note if there is no release note block#803
pacoxu wants to merge 1 commit into
kubernetes-sigs:mainfrom
pacoxu:append-release-note

Conversation

@pacoxu

@pacoxu pacoxu commented Jul 17, 2026

Copy link
Copy Markdown
Member

Here is an example: kubernetes/kubernetes#140600 (comment).

This PR help to support /release-note-edit on no release-note block PR description.

@netlify

netlify Bot commented Jul 17, 2026

Copy link
Copy Markdown

Deploy Preview for k8s-prow ready!

Name Link
🔨 Latest commit 94c6c56
🔍 Latest deploy log https://app.netlify.com/projects/k8s-prow/deploys/6a59ceccc138640008817cde
😎 Deploy Preview https://deploy-preview-803--k8s-prow.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kubernetes-prow
kubernetes-prow Bot requested a review from cjwagner July 17, 2026 06:42
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pacoxu
Once this PR has been reviewed and has the lgtm label, please assign cjwagner for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the area/plugins Issues or PRs related to prow's plugins for the hook component label Jul 17, 2026
@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 17, 2026
@pacoxu

pacoxu commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

/assign @petr-muller @cblecker

// Splice in the contents of the new release note block to the top level comment.
// This accounts for all older regex matches.
b := []byte(ic.Issue.Body)
replaced := append(b[:i[2]], append([]byte("\r\n"+strings.TrimSpace(newNote)+"\r\n"), b[i[3]:]...)...)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new append path above correctly detects \n vs \r\n and adapts, but this splice path still hardcodes \r\n. For a body using LF line endings (e.g., a PR created via API), this would inject CRLF around the note content, creating mixed line endings.

Since you've already written the detection logic, consider extracting the lineEnding variable before the if/else so both paths share it.

fc.Issues[issueNum] = &github.Issue{Number: issueNum, User: github.User{Login: "user"}}
},
expectedNote: "```release-note\nThe new note\n```\n",
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both new test cases use LF-only bodies. Since GitHub's web UI typically produces CRLF bodies, consider adding a test with a CRLF body that has no existing release-note block (e.g., Body: "Top\r\nBelow") to exercise the strings.Contains(ic.Issue.Body, "\r\n") branch in the append path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/plugins Issues or PRs related to prow's plugins for the hook component cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants