Merge pull request woocommerce/woocommerce-admin#2433 from woocommerce/changelog/omit-unmerged-prs

Changelog: Omit unmerged pull requests
This commit is contained in:
Paul Sealock 2019-06-17 09:56:23 +12:00 committed by GitHub
commit 31f805f651
1 changed files with 24 additions and 7 deletions

View File

@ -46,6 +46,20 @@ const isCollaborator = async ( username ) => {
});
}
const isMergedPullRequest = async ( pullRequestUrl ) => {
const options = {
url: pullRequestUrl,
headers,
json: true,
};
return requestPromise( options )
.then( data => data.merged )
.catch( err => {
console.log( '🤯' );
console.log( err.message );
});
}
const writeEntry = async ( content_url ) => {
const options = {
url: content_url,
@ -55,13 +69,16 @@ const writeEntry = async ( content_url ) => {
return requestPromise( options )
.then( async data => {
if ( data.pull_request ) {
const collaborator = await isCollaborator( data.user.login );
const type = getPullRequestType( data.labels );
const labels = getLabels( data.labels );
const labelTag = labels.length ? `(${ labels })` : '';
const authorTag = collaborator ? '' : `👏 @${ data.user.login }`;
const entry = `- ${ type }: ${ data.title } #${ data.number } ${ labelTag } ${ authorTag }`;
console.log( entry );
const isMerged = await isMergedPullRequest( data.pull_request.url );
if ( isMerged ) {
const collaborator = await isCollaborator( data.user.login );
const type = getPullRequestType( data.labels );
const labels = getLabels( data.labels );
const labelTag = labels.length ? `(${ labels })` : '';
const authorTag = collaborator ? '' : `👏 @${ data.user.login }`;
const entry = `- ${ type }: ${ data.title } #${ data.number } ${ labelTag } ${ authorTag }`;
console.log( entry );
}
}
} )
.catch( err => {