Skip to content

Commit

Permalink
Project Management Automation: Log skipped tasks and retain wrapped t…
Browse files Browse the repository at this point in the history
…ask names. (#20034)

* Project Management Automation: Log skipped tasks and retain wrapped task names.

* Project Management Automation: Set function name properly.
  • Loading branch information
epiqueras committed Feb 5, 2020
1 parent 056d7c1 commit 6e33ffb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/project-management-automation/lib/if-not-fork.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Internal dependencies
*/
const debug = require( './debug' );

/**
* Higher-order function which executes and returns the result of the given
* handler only if the enhanced function is called with a payload indicating a
Expand All @@ -8,14 +13,17 @@
* @return {Function} Enhanced task.
*/
function ifNotFork( handler ) {
return ( payload, ...args ) => {
const newHandler = ( payload, ...args ) => {
if (
payload.pull_request.head.repo.full_name ===
payload.pull_request.base.repo.full_name
) {
return handler( payload, ...args );
}
debug( `main: Skipping ${ handler.name } because we are in a fork.` );
};
Object.defineProperty( newHandler, 'name', { value: handler.name } );
return newHandler;
}

module.exports = ifNotFork;

0 comments on commit 6e33ffb

Please sign in to comment.