diff --git a/lib/node-labels.js b/lib/node-labels.js index 8cdc447d..51e13b8f 100644 --- a/lib/node-labels.js +++ b/lib/node-labels.js @@ -118,9 +118,19 @@ function hasAllSubsystems (arr) { }) } +// This function is needed to help properly identify when a PR should always +// (just) be labeled as 'doc' when it is all changes in doc/api/ that do not +// match subsystem names (e.g. _toc.md, all.md) +function hasAllDocChanges (arr) { + return arr.every((val) => { + return /^doc\//.test(val) + }) +} + function matchExclusiveSubSystem (filepathsChanged) { const isExclusive = filepathsChanged.every(matchesAnExclusiveLabel) var labels = matchSubSystemsByRegex(exclusiveLabelsMap, filepathsChanged) + // if there are multiple API doc changes, do not apply subsystem tags for now if (isExclusive && labels.includes('doc') && @@ -128,7 +138,7 @@ function matchExclusiveSubSystem (filepathsChanged) { const nonDocLabels = labels.filter((val) => { return val !== 'doc' }) - if (hasAllSubsystems(nonDocLabels)) { + if (hasAllSubsystems(nonDocLabels) || hasAllDocChanges(filepathsChanged)) { labels = ['doc'] } else { labels = [] diff --git a/test/unit/node-labels.test.js b/test/unit/node-labels.test.js index 92340cc9..fbaa86a6 100644 --- a/test/unit/node-labels.test.js +++ b/test/unit/node-labels.test.js @@ -428,3 +428,14 @@ tap.test('label: dont-land-on labels for WHATWG URL', (t) => { t.end() }) + +tap.test('label: doc label for non-subsystem API doc changes', (t) => { + const labels = nodeLabels.resolveLabels([ + 'doc/api/_toc.md', + 'doc/api/all.md' + ]) + + t.same(labels, ['doc']) + + t.end() +})