Repository: kubernetes/release (go)

Issue:
[script] Generation of release notes picks up reverted PR instead of the PR which reverts it
#### What happened:

We were generating release notes for Kueue v0.10.4 using the script with the following command 

```
> release-notes --org kubernetes-sigs --repo kueue --branch release-0.10 --start-sha c79419eb5b3b0021621805a73bec2ff58c398d8b --end-sha 036b210650d64a60458fbdf45bc320c0803d4294 --dependencies=false --required-author="" --debug
WARN No subcommand specified, running "generate"  
INFO Using output format: markdown                
INFO Gathering release notes                      
DEBU Using authenticated GitHub client             file="github/github.go:217"
INFO Starting to process commit 1 of 7 (14.29%): 036b210650d64a60458fbdf45bc320c0803d4294  file="notes/notes.go:699"
INFO Starting to process commit 2 of 7 (28.57%): f692c87796eb6e7cffb8be3fbc90d9e10c0a457b  file="notes/notes.go:699"
INFO Starting to process commit 3 of 7 (42.86%): 2401fa1a0dcc57c3c17e953a2dd92adb5e67f225  file="notes/notes.go:699"
INFO Starting to process commit 4 of 7 (57.14%): 700426b0438d6d9fc75172ec1228e6c31163f06d  file="notes/notes.go:699"
INFO Starting to process commit 5 of 7 (71.43%): 6e435fccbbe61bdd3658d77a840cc2bf11fb2b2b  file="notes/notes.go:699"
INFO Starting to process commit 6 of 7 (85.71%): 7c52602ba8f8ab00d0b215f6f56a3263c6a11bf4  file="notes/notes.go:699"
INFO Starting to process commit 7 of 7 (100.00%): c79419eb5b3b0021621805a73bec2ff58c398d8b  file="notes/notes.go:699"
DEBU Got PR #4779 for commit: 2401fa1a0dcc57c3c17e953a2dd92adb5e67f225  file="notes/notes.go:803"
INFO PR #4779 contains exclusion (release-note-none)  file="notes/notes.go:812"
DEBU Got PR #4716 for commit: 7c52602ba8f8ab00d0b215f6f56a3263c6a11bf4  file="notes/notes.go:803"
INFO PR #4716 contains exclusion (release-note-none)  file="notes/notes.go:812"
DEBU Got PR #4165 for commit: f692c87796eb6e7cffb8be3fbc90d9e10c0a457b  file="notes/notes.go:803"
INFO PR #4165 seems to contain a release note      file="notes/notes.go:829"
DEBU Got PR #4823 for commit: 036b210650d64a60458fbdf45bc320c0803d4294  file="notes/notes.go:803"
INFO PR #4823 seems to contain a release note      file="notes/notes.go:829"
DEBU Got PR #4732 for commit: 6e435fccbbe61bdd3658d77a840cc2bf11fb2b2b  file="notes/notes.go:803"
INFO PR #4732 contains exclusion (release-note-none)  file="notes/notes.go:812"
DEBU Got PR #4689 for commit: c79419eb5b3b0021621805a73bec2ff58c398d8b  file="notes/notes.go:803"
INFO PR #4689 contains exclusion (release-note-none)  file="notes/notes.go:812"
DEBU Got PR #4777 for commit: 700426b0438d6d9fc75172ec1228e6c31163f06d  file="notes/notes.go:803"
INFO PR #4777 contains exclusion (release-note-none)  file="notes/notes.go:812"
INFO Checking PRs for mapped data                  file="notes/notes.go:297"
INFO Finished gathering release notes in 1.168086917s  file="notes/notes.go:265"
INFO Got 2 release notes, performing rendering     file="release-notes/main.go:51"
INFO Release notes written to file: /tmp/release-notes-3165391239  file="release-notes/main.go:152"
```
The generated notes were:
```
## Changes by Kind

### Bug or Regression

- Fix bug which resulted in under-utilization of the resources in a Cohort.
  Now, when a ClusterQueue is configured with `preemption.reclaimWithinCohort: Any`,
  its resources can be lent out more freely, as we are certain that we can reclaim
  them later. Please see PR #4813 for detailed description of scenario. (#4823, @gabesaba)
- Update FairSharing to be incompatible with ClusterQueue.Preemption.BorrowWithinCohort. Using these parameters together is a no-op, and will be validated against in future releases. This change fixes an edge case which triggered an infinite preemption loop when these two parameters were combined. (#4165, @gabesaba)% 
```
but this is not good, because PR [4165](https://github.com/kubernetes-sigs/kueue/pull/4165) is the PR that was reverted on this branch.  The actual PR which should be reported is [4819](https://github.com/kubernetes-sigs/kueue/pull/4819).

#### What you expected to happen:

The script should corrently pick up the reverting PR which actually even had its note.

#### How to reproduce it (as minimally and precisely as possible):

The steps described above still repro the wrong generation using Kueue release-0.10 branch.

#### Anything else we need to know?:

 We adjusted the notes manually.

Pull request:
Include revert PR instead of the reverted one in release notes
<!--  Thanks for sending a pull request!  Here are some tips for you:

- If this is your first time, please read our contributor guidelines: https://git.k8s.io/community/contributors/guide#your-first-contribution and developer guide https://git.k8s.io/community/contributors/devel/development.md#development-guide
- Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request. For reference on required PR/issue labels, read here:
https://git.k8s.io/community/contributors/devel/sig-release/release.md#issuepr-kind-label
- If you want *faster* PR reviews, read how: https://git.k8s.io/community/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
- If the PR is unfinished, see how to mark it: https://git.k8s.io/community/contributors/guide/pull-requests.md#marking-unfinished-pull-requests
-->

#### What type of PR is this?

<!--
Add one of the following kinds:
/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind design

Optionally add one or more of the following kinds if applicable:
/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

/kind bug

#### What this PR does / why we need it:
As described in #3966, the release notes include the reverted PRs instead of the revert PRs.

#### Which issue(s) this PR fixes:

<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.

Fixes #

or

None
-->

Fixes #3966 

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?

<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".

For more information on release notes see: https://git.k8s.io/community/contributors/guide/release-notes.md
-->

```release-note
Fix release notes to include the revert PR instead of the reverted one.
```


Patch:
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 1a13ebd8..1e133a62 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -39,7 +39,7 @@ jobs:
 
     steps:
     - name: Harden Runner
-      uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
+      uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
       with:
         disable-sudo: true
         egress-policy: block
diff --git a/.github/workflows/depsreview.yml b/.github/workflows/depsreview.yml
index cff17aa2..bf230576 100644
--- a/.github/workflows/depsreview.yml
+++ b/.github/workflows/depsreview.yml
@@ -12,7 +12,7 @@ jobs:
 
     steps:
       - name: Harden Runner
-        uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
+        uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
         with:
           disable-sudo: true
           egress-policy: block
@@ -26,4 +26,4 @@ jobs:
         uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
 
       - name: 'Dependency Review'
-        uses: actions/dependency-review-action@ce3cf9537a52e8119d91fd484ab5b8a807627bf8 # v4.6.0
+        uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index a8e9f4df..b9ecf6c4 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -19,7 +19,7 @@ jobs:
 
     steps:
       - name: Harden Runner
-        uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
+        uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
         with:
           disable-sudo: true
           egress-policy: audit
@@ -65,7 +65,7 @@ jobs:
 
     steps:
       - name: Harden Runner
-        uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
+        uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
         with:
           disable-sudo: true
           egress-policy: audit
diff --git a/.github/workflows/snapshot.yaml b/.github/workflows/snapshot.yaml
index 5df62a1f..22b545c0 100644
--- a/.github/workflows/snapshot.yaml
+++ b/.github/workflows/snapshot.yaml
@@ -13,7 +13,7 @@ jobs:
 
     steps:
       - name: Harden Runner
-        uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
+        uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
         with:
           disable-sudo: true
           egress-policy: audit
@@ -61,7 +61,7 @@ jobs:
 
     steps:
       - name: Harden Runner
-        uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
+        uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
         with:
           disable-sudo: true
           egress-policy: audit
diff --git a/go.mod b/go.mod
index f0c8d533..0fa75b6b 100644
--- a/go.mod
+++ b/go.mod
@@ -35,8 +35,8 @@ require (
 	github.com/tj/go-spin v1.1.0
 	github.com/yuin/goldmark v1.7.8
 	golang.org/x/net v0.38.0
-	golang.org/x/oauth2 v0.29.0
-	golang.org/x/text v0.24.0
+	golang.org/x/oauth2 v0.28.0
+	golang.org/x/text v0.23.0
 	google.golang.org/api v0.221.0
 	gopkg.in/yaml.v2 v2.4.0
 	k8s.io/apimachinery v0.32.3
@@ -296,7 +296,7 @@ require (
 	golang.org/x/crypto v0.36.0 // indirect
 	golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
 	golang.org/x/mod v0.22.0 // indirect
-	golang.org/x/sync v0.13.0 // indirect
+	golang.org/x/sync v0.12.0 // indirect
 	golang.org/x/sys v0.31.0 // indirect
 	golang.org/x/term v0.30.0 // indirect
 	golang.org/x/time v0.10.0 // indirect
diff --git a/go.sum b/go.sum
index c68e6a36..21fc8315 100644
--- a/go.sum
+++ b/go.sum
@@ -1052,8 +1052,8 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr
 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98=
-golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
+golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=
+golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -1066,8 +1066,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
 golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
-golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
-golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
+golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
+golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
 golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -1143,8 +1143,8 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
 golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
 golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
 golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
-golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
-golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
+golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
+golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
 golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
diff --git a/pkg/notes/notes.go b/pkg/notes/notes.go
index a2457dea..1eeac675 100644
--- a/pkg/notes/notes.go
+++ b/pkg/notes/notes.go
@@ -1136,6 +1136,13 @@ func prsNumForCommitFromMessage(commitMessage string) (prs []int, err error) {
 		prs = append(prs, pr)
 	}
 
+	regex = regexp.MustCompile(`\(#(?P<number>\d+)\)\s*\n\nThis reverts commit`)
+
+	pr = prForRegex(regex, commitMessage)
+	if pr != 0 {
+		prs = append(prs, pr)
+	}
+
 	// If the PR was squash merged, the regexp is different
 	regex = regexp.MustCompile(`\(#(?P<number>\d+)\)`)
 


Test patch:
diff --git a/pkg/notes/notes_test.go b/pkg/notes/notes_test.go
index b56f057d..199ab3ca 100644
--- a/pkg/notes/notes_test.go
+++ b/pkg/notes/notes_test.go
@@ -223,6 +223,14 @@ func TestGetPRNumberFromCommitMessage(t *testing.T) {
 			commitMessage:    "Add swapoff to centos so kubelet starts (#504)",
 			expectedPRNumber: 504,
 		},
+		{
+			name: "Get PR number from revert commit",
+			commitMessage: `Revert "some pr (#1000)" (#1234)
+
+
+This reverts commit abcdef1234567890abcdef1234567890abcdef12.`,
+			expectedPRNumber: 1234,
+		},
 	}
 
 	for _, tc := range testCases {