Skip to content

Instantly share code, notes, and snippets.

@psealock
Last active August 4, 2021 05:14
Show Gist options
  • Save psealock/cd8c60ec34f776c4bf0f88a3aa7a3537 to your computer and use it in GitHub Desktop.
Save psealock/cd8c60ec34f776c4bf0f88a3aa7a3537 to your computer and use it in GitHub Desktop.
/**
* Usage: node ./transfer.js <destination repo>
* Run from the root of source repo.
* Requires `hub`
*/
const { exec } = require( 'child_process' );
const destinationRepo = process.argv[ 2 ];
exec( 'hub issue', ( error, stdout ) => {
if ( error !== null ) {
console.log( `exec error: ${ error }` );
}
const rx = /(?<=#)\d+/gm;
const issueNumbers = stdout
.match( rx )
.map( ( str ) => parseInt( str, 10 ) );
issueNumbers.forEach( ( issueNumber ) => {
exec(
`hub issue transfer ${ issueNumber } ${ destinationRepo }`,
( transferError, transferOut, transferErr ) => {
if ( transferError !== null ) {
console.log( `exec error: ${ transferError }` );
}
if ( transferErr ) {
console.log( transferErr );
}
if ( transferOut ) {
console.log( 'Issue transfered: ' + transferOut );
}
}
);
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment