Skip to content

Commit 81a901c

Browse files
authored
chore: recognize prefixed Node.js PR titles (#9915)
## Summary - recognize existing Node.js npm update PRs with branch prefixes such as `[v22.x]` - preserve an existing PR title when updating it ## Background The create-node-pr workflow successfully regenerated and force-pushed nodejs/node#64884, but then failed because the existing-PR parser treated `[v22.x] 10.9.9` as the npm version. It attempted to create a duplicate PR instead of editing the existing one. This extracts the version following the canonical `deps: upgrade npm to` text regardless of any title prefix. Existing base-branch filtering continues to distinguish PRs targeting different Node.js release lines. Reproduction: https://github.com/npm/cli/actions/runs/32768286326 Copilot-Session: 14a9626a-4d0e-4be3-b06c-b6676ecb3895
1 parent d6c6122 commit 81a901c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎scripts/create-node-pr.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,13 @@ const main = async (spec, branch = 'main', opts) => withTempDir(CWD, async (tmpD
238238

239239
let existingPr = null
240240
const closePrs = []
241+
const npmMessagePrefix = npmMessage('')
241242

242243
for (const pr of npmPrs) {
243-
const prVersion = pr.title.replace(npmMessage(''), '').trim()
244+
const npmMessageIndex = pr.title.indexOf(npmMessagePrefix)
245+
const prVersion = npmMessageIndex === -1
246+
? null
247+
: pr.title.slice(npmMessageIndex + npmMessagePrefix.length).trim()
244248
log.silly('checking existing PR', prVersion, pr)
245249

246250
if (!existingPr && prVersion === npmVersion.toString()) {
@@ -259,7 +263,7 @@ const main = async (spec, branch = 'main', opts) => withTempDir(CWD, async (tmpD
259263
nodePrArgs,
260264
(existingPr ? ['edit', existingPr.number] : ['create', '-H', `${npmHost.user}:${npmBranch}`]),
261265
'-B', nodeBranch,
262-
'-t', npmMessage(),
266+
(existingPr ? [] : ['-t', npmMessage()]),
263267
].flat()
264268

265269
if (dryRun) {

0 commit comments

Comments
 (0)