Created
April 15, 2019 14:46
-
-
Save aduth/901b1604dc7a9ba520db0a06deadec05 to your computer and use it in GitHub Desktop.
Generate cherry-pick commands from a set of pull requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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