-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into update/wp-requireme…
…nts-wp57
- Loading branch information
Showing
179 changed files
with
3,727 additions
and
7,687 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* global GitHub */ | ||
|
||
/** | ||
* Get labels on a PR. | ||
* | ||
* @param {GitHub} octokit - Initialized Octokit REST client. | ||
* @param {string} owner - Repository owner. | ||
* @param {string} repo - Repository name. | ||
* @param {string} number - PR number. | ||
* | ||
* @returns {Promise<Array>} Promise resolving to an array of all labels for that PR. | ||
*/ | ||
async function getLabels( octokit, owner, repo, number ) { | ||
const labelList = []; | ||
|
||
for await ( const response of octokit.paginate.iterator( octokit.issues.listLabelsOnIssue, { | ||
owner: owner.login, | ||
repo, | ||
issue_number: +number, | ||
} ) ) { | ||
response.data.map( label => { | ||
labelList.push( label.name ); | ||
} ); | ||
} | ||
|
||
return labelList; | ||
} | ||
|
||
module.exports = getLabels; |
42 changes: 42 additions & 0 deletions
42
.github/actions/repo-gardening/src/get-next-valid-milestone.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
const moment = require( 'moment' ); | ||
|
||
/* global GitHub, OktokitIssuesListMilestonesForRepoResponseItem */ | ||
|
||
/** | ||
* Returns a promise resolving to the next valid milestone, if exists. | ||
* | ||
* @param {GitHub} octokit - Initialized Octokit REST client. | ||
* @param {string} owner - Repository owner. | ||
* @param {string} repo - Repository name. | ||
* @param {string} plugin - Plugin slug. | ||
* | ||
* @returns {Promise<OktokitIssuesListMilestonesForRepoResponseItem|void>} Promise resolving to milestone, if exists. | ||
*/ | ||
async function getNextValidMilestone( octokit, owner, repo, plugin = 'jetpack' ) { | ||
const options = octokit.issues.listMilestones.endpoint.merge( { | ||
owner, | ||
repo, | ||
state: 'open', | ||
sort: 'due_on', | ||
direction: 'asc', | ||
} ); | ||
|
||
const responses = octokit.paginate.iterator( options ); | ||
|
||
for await ( const response of responses ) { | ||
// Find a milestone which name is a version number | ||
// and it's due dates is earliest in a future | ||
const reg = new RegExp( plugin + '/d.d' ); | ||
const nextMilestone = response.data | ||
.filter( m => m.title.match( reg ) ) | ||
.sort( ( m1, m2 ) => parseFloat( m1.title ) - parseFloat( m2.title ) ) | ||
.find( milestone => milestone.due_on && moment( milestone.due_on ) > moment() ); | ||
|
||
return nextMilestone; | ||
} | ||
} | ||
|
||
module.exports = getNextValidMilestone; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* global GitHub */ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
const getLabels = require( './get-labels' ); | ||
|
||
/** | ||
* Get the name of the plugin concerned by this PR. | ||
* | ||
* @param {GitHub} octokit - Initialized Octokit REST client. | ||
* @param {string} owner - Repository owner. | ||
* @param {string} repo - Repository name. | ||
* @param {string} number - PR / Issue number. | ||
* | ||
* @returns {Promise<Array>} Promise resolving to an array of all the plugins touched by that PR. | ||
*/ | ||
async function getPluginNames( octokit, owner, repo, number ) { | ||
const plugins = []; | ||
const labels = await getLabels( octokit, owner, repo, number ); | ||
labels.map( label => { | ||
const plugin = label.match( /^\[Plugin\]\s(?<pluginName>[^/]*)$/ ); | ||
if ( plugin && plugin.groups.pluginName ) { | ||
plugins.push( plugin.groups.pluginName.toLowerCase() ); | ||
} | ||
} ); | ||
|
||
return plugins; | ||
} | ||
|
||
module.exports = getPluginNames; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
const debug = require( './debug' ); | ||
|
||
/* global WPAutomationTask */ | ||
|
||
/** | ||
* Higher-order function which executes and returns the result of the given | ||
* handler only if the PR is not currently closed. | ||
* | ||
* @param {WPAutomationTask} handler - Original task. | ||
* | ||
* @returns {WPAutomationTask} Enhanced task. | ||
*/ | ||
function ifNotClosed( handler ) { | ||
const newHandler = ( payload, octokit ) => { | ||
if ( payload.pull_request.state !== 'closed' ) { | ||
return handler( payload, octokit ); | ||
} | ||
debug( `main: Skipping ${ handler.name } because the PR is closed.` ); | ||
}; | ||
Object.defineProperty( newHandler, 'name', { value: handler.name } ); | ||
return newHandler; | ||
} | ||
|
||
module.exports = ifNotClosed; |
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
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
Oops, something went wrong.