1+ const retrieveLabelDirectory = require ( '../../utils/retrieve-label-directory' ) ;
2+
3+ // Use labelKeys to retrieve current labelNames from directory
4+ const [
5+ nonPrContribution
6+ ] = [
7+ 'NEW-nonPrContribution'
8+ ] . map ( retrieveLabelDirectory ) ;
9+
10+ // ==================================================
11+
112/**
213 * Checks whether a closed issue has a linked PR or one of the labels to excuse
314 * this GitHub Actions workflow.
@@ -14,15 +25,22 @@ async function hasLinkedPrOrExcusableLabel({ github, context }) {
1425
1526 const labels = context . payload . issue . labels . map ( ( label ) => label . name ) ;
1627
28+ const consoleMessageAllowClose =
29+ `Issue #${ issueNumber } is allowed to be closed.` ;
30+
1731 // --------------------------------------------------
1832
1933 // Check if the issue has the labels that will avoid re-opening it.
2034 if (
2135 labels . some (
22- ( label ) => label === 'non-PR contribution' || label . includes ( 'Ignore' )
36+ ( label ) =>
37+ label === nonPrContribution || label . toLowerCase ( ) . includes ( 'ignore' )
2338 )
24- )
39+ ) {
40+ console . info ( consoleMessageAllowClose ) ;
2541 return true ;
42+ }
43+
2644 console . info (
2745 `Issue #${ issueNumber } does not have ` +
2846 `the necessary labels to excuse reopening it.`
@@ -46,6 +64,7 @@ async function hasLinkedPrOrExcusableLabel({ github, context }) {
4664 issue : issueNumber ,
4765 } ;
4866
67+ // Determine if there is a linked PR.
4968 try {
5069 const response = await github . graphql ( query , variables ) ;
5170
@@ -54,7 +73,10 @@ async function hasLinkedPrOrExcusableLabel({ github, context }) {
5473
5574 console . debug ( `Number of linked PRs found: ${ numLinkedPrs } .` ) ;
5675
57- if ( numLinkedPrs > 0 ) return true ;
76+ if ( numLinkedPrs > 0 ) {
77+ console . info ( consoleMessageAllowClose ) ;
78+ return true ;
79+ }
5880 } catch ( err ) {
5981 throw new Error (
6082 `Can not find issue #${ issueNumber } or its PR count; error = ${ err } `
@@ -63,6 +85,7 @@ async function hasLinkedPrOrExcusableLabel({ github, context }) {
6385 console . info ( `Issue #${ issueNumber } does not have a linked PR.` ) ;
6486
6587 // If the issue does not have a linked PR or any of the excusable labels.
88+ console . info ( `Issue #${ issueNumber } is not allowed to be closed.` ) ;
6689 return false ;
6790}
6891
0 commit comments