Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport tools: sort PRs to be cherry picked by merged/closed date #52667

Merged
merged 4 commits into from
Jul 17, 2023
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
19 changes: 16 additions & 3 deletions bin/cherry-pick.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,25 @@ 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 } ) => ( {
const PRs = items.map( ( { id, number, title, pull_request, closed_at } ) => ( {
id,
number,
title,
} ) );
console.log( 'Found the following PRs to cherry-pick: ' );
closed_at,
pull_request,
} ) ).sort( ( a, b ) => {
/*
* `closed_at` and `pull_request.merged_at` are _usually_ the same,
* but let's prefer the latter if it's available.
*/
if ( a?.pull_request?.merged_at && b?.pull_request?.merged_at ) {
return new Date( a?.pull_request?.merged_at ) - new Date( b?.pull_request?.merged_at );
}
return new Date( a.closed_at ) - new Date( b.closed_at );
} );


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
Loading