Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions bin/cherry-pick.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const LABEL = process.argv[ 2 ] || 'Backport to WP Beta/RC';
const BRANCH = getCurrentBranch();
const GITHUB_CLI_AVAILABLE = spawnSync( 'gh', [ 'auth', 'status' ] )
?.stdout?.toString()
.includes( '✓ Logged in to github.com as' );
.includes( '✓ Logged in to github.com' );

const AUTO_PROPAGATE_RESULTS_TO_GITHUB = GITHUB_CLI_AVAILABLE;

Expand Down Expand Up @@ -114,16 +114,23 @@ async function fetchPRs() {
const { items } = await GitHubFetch(
`/search/issues?q=is:pr state:closed sort:updated label:"${ LABEL }" repo:WordPress/gutenberg`
);
const PRs = items.map( ( { id, number, title, pull_request, closed_at } ) => ( {
id,
number,
title,
pull_request,
} ) )
const PRs = items
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are all just linting changes.

.map( ( { id, number, title, pull_request, closed_at } ) => ( {
id,
number,
title,
pull_request,
} ) )
.filter( ( { pull_request } ) => !! pull_request?.merged_at )
.sort( ( a, b ) => new Date( a?.pull_request?.merged_at ) - new Date( b?.pull_request?.merged_at ) );
.sort(
( a, b ) =>
new Date( a?.pull_request?.merged_at ) -
new Date( b?.pull_request?.merged_at )
);

console.log( 'Found the following PRs to cherry-pick (sorted by closed date in ascending order): ' );
console.log(
'Found the following PRs to cherry-pick (sorted by closed date in ascending order): '
);
PRs.forEach( ( { number, title } ) =>
console.log( indent( `#${ number } – ${ title }` ) )
);
Expand Down