Skip to content

Instantly share code, notes, and snippets.

@aduth
Created April 15, 2019 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aduth/901b1604dc7a9ba520db0a06deadec05 to your computer and use it in GitHub Desktop.
Save aduth/901b1604dc7a9ba520db0a06deadec05 to your computer and use it in GitHub Desktop.
Generate cherry-pick commands from a set of pull requests
const { get } = require( 'https' );
const { parse } = require( 'url' );
const pulls = [
'https://github.com/WordPress/gutenberg/pull/14003',
'https://github.com/WordPress/gutenberg/pull/14469',
'https://github.com/WordPress/gutenberg/pull/14475',
'https://github.com/WordPress/gutenberg/pull/14681',
'https://github.com/WordPress/gutenberg/pull/14693',
'https://github.com/WordPress/gutenberg/pull/14711',
'https://github.com/WordPress/gutenberg/pull/14771',
'https://github.com/WordPress/gutenberg/pull/14772',
'https://github.com/WordPress/gutenberg/pull/14785',
'https://github.com/WordPress/gutenberg/pull/14804',
'https://github.com/WordPress/gutenberg/pull/14813',
'https://github.com/WordPress/gutenberg/pull/14822',
'https://github.com/WordPress/gutenberg/pull/14854',
'https://github.com/WordPress/gutenberg/pull/14876',
'https://github.com/WordPress/gutenberg/pull/14877',
'https://github.com/WordPress/gutenberg/pull/14894',
'https://github.com/WordPress/gutenberg/pull/14916',
'https://github.com/WordPress/gutenberg/pull/14925',
'https://github.com/WordPress/gutenberg/pull/14936',
'https://github.com/WordPress/gutenberg/pull/14938',
'https://github.com/WordPress/gutenberg/pull/14944',
'https://github.com/WordPress/gutenberg/pull/14955',
];
( async () => {
const commits = [];
await Promise.all( pulls.map( ( url ) => new Promise( ( resolve ) => {
url = url
.replace( '//github.com/', '//api.github.com/repos/' )
.replace( '/pull/', '/pulls/' );
get( {
...parse( url ),
headers: {
'User-Agent': 'Gutenberg'
},
agent: false,
}, async ( response ) => {
let data = '';
for await ( const chunk of response ) {
data += chunk;
}
data = JSON.parse( data );
commits.push( [ data.merge_commit_sha, data.merged_at ] );
resolve();
} );
} ) ) );
commits
.sort( ( a, b ) => a[ 1 ].localeCompare( b[ 1 ] ) )
.forEach( ( [ sha ] ) => console.log( `git cherry-pick ${ sha.slice( 0, 7 ) }` ) );
} )();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment