From 80664fadacfbe0c315a29ada3e7e1cc77ca05a73 Mon Sep 17 00:00:00 2001 From: Ella <ella@vandurpe.com> Date: Tue, 18 Jun 2024 10:22:08 +0300 Subject: [PATCH 1/3] Fix cherry-pick script, missing --repo arg --- bin/cherry-pick.mjs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/bin/cherry-pick.mjs b/bin/cherry-pick.mjs index 5c6c3ba3c9e515..cc46d921b75fb9 100644 --- a/bin/cherry-pick.mjs +++ b/bin/cherry-pick.mjs @@ -380,15 +380,34 @@ function reportSummaryNextSteps( successes, failures ) { function GHcommentAndRemoveLabel( pr ) { const { number, cherryPickHash } = pr; const comment = prComment( cherryPickHash ); + const repo = 'WordPress/gutenberg'; try { - cli( 'gh', [ 'pr', 'comment', number, '--body', comment ] ); - cli( 'gh', [ 'pr', 'edit', number, '--remove-label', LABEL ] ); + cli( 'gh', [ + 'pr', + 'comment', + number, + '--repo', + repo, + '--body', + comment, + ] ); + cli( 'gh', [ + 'pr', + 'edit', + number, + '--repo', + repo, + '--remove-label', + LABEL, + ] ); if ( LABEL === 'Backport to WP Beta/RC' ) { cli( 'gh', [ 'pr', 'edit', number, + '--repo', + repo, '--add-label', BACKPORT_COMPLETED_LABEL, ] ); From 0c445f256fc95424db7d40adbdc353db468dc5b6 Mon Sep 17 00:00:00 2001 From: Ella <ella@vandurpe.com> Date: Tue, 18 Jun 2024 10:52:07 +0300 Subject: [PATCH 2/3] Min diff --- bin/cherry-pick.mjs | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/bin/cherry-pick.mjs b/bin/cherry-pick.mjs index cc46d921b75fb9..2666c2eed7ffa1 100644 --- a/bin/cherry-pick.mjs +++ b/bin/cherry-pick.mjs @@ -380,34 +380,17 @@ function reportSummaryNextSteps( successes, failures ) { function GHcommentAndRemoveLabel( pr ) { const { number, cherryPickHash } = pr; const comment = prComment( cherryPickHash ); - const repo = 'WordPress/gutenberg'; + const repo = [ '--repo', 'WordPress/gutenberg' ]; try { - cli( 'gh', [ - 'pr', - 'comment', - number, - '--repo', - repo, - '--body', - comment, - ] ); - cli( 'gh', [ - 'pr', - 'edit', - number, - '--repo', - repo, - '--remove-label', - LABEL, - ] ); + cli( 'gh', [ 'pr', 'comment', number, ...repo, '--body', comment ] ); + cli( 'gh', [ 'pr', 'edit', number, ...repo, '--remove-label', LABEL ] ); if ( LABEL === 'Backport to WP Beta/RC' ) { cli( 'gh', [ 'pr', 'edit', number, - '--repo', - repo, + ...repo, '--add-label', BACKPORT_COMPLETED_LABEL, ] ); From 555040c933d37c3e398f27421b1c6bd6ca3c3a19 Mon Sep 17 00:00:00 2001 From: Ella <ella@vandurpe.com> Date: Tue, 18 Jun 2024 12:27:36 +0300 Subject: [PATCH 3/3] Update hardcoded places --- bin/cherry-pick.mjs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/cherry-pick.mjs b/bin/cherry-pick.mjs index 2666c2eed7ffa1..b8661e696d7bd3 100644 --- a/bin/cherry-pick.mjs +++ b/bin/cherry-pick.mjs @@ -6,6 +6,7 @@ import readline from 'readline'; import { spawnSync } from 'node:child_process'; +const REPO = 'WordPress/gutenberg'; const LABEL = process.argv[ 2 ] || 'Backport to WP Beta/RC'; const BACKPORT_COMPLETED_LABEL = 'Backported to WP Core'; const BRANCH = getCurrentBranch(); @@ -113,7 +114,7 @@ function cli( command, args, pipe = false ) { */ async function fetchPRs() { const { items } = await GitHubFetch( - `/search/issues?per_page=100&q=is:pr state:closed sort:updated label:"${ LABEL }" repo:WordPress/gutenberg` + `/search/issues?per_page=100&q=is:pr state:closed sort:updated label:"${ LABEL }" repo:${ REPO }` ); const PRs = items // eslint-disable-next-line camelcase @@ -143,7 +144,7 @@ async function fetchPRs() { const PRsWithMergeCommit = []; for ( const PR of PRs ) { const { merge_commit_sha: mergeCommitHash } = await GitHubFetch( - '/repos/WordPress/Gutenberg/pulls/' + PR.number + `/repos/${ REPO }/pulls/` + PR.number ); PRsWithMergeCommit.push( { ...PR, @@ -380,7 +381,7 @@ function reportSummaryNextSteps( successes, failures ) { function GHcommentAndRemoveLabel( pr ) { const { number, cherryPickHash } = pr; const comment = prComment( cherryPickHash ); - const repo = [ '--repo', 'WordPress/gutenberg' ]; + const repo = [ '--repo', REPO ]; try { cli( 'gh', [ 'pr', 'comment', number, ...repo, '--body', comment ] ); cli( 'gh', [ 'pr', 'edit', number, ...repo, '--remove-label', LABEL ] ); @@ -446,7 +447,7 @@ function reportFailure( { number, title, error, mergeCommitHash } ) { * @return {string} PR URL. */ function prUrl( number ) { - return `https://github.com/WordPress/gutenberg/pull/${ number } `; + return `https://github.com/${ REPO }/pull/${ number } `; } /**