Skip to content

Commit a2c330d

Browse files
committed
Fix for bad node core PR exclusive labels. (#34)
This fixes some bad labelling by ensuring that *every* file affected in the PR actually matches an exclusive label when we're checking for exclusive labels. Refs nodejs/node#6448 nodejs/node#6432 Closes #33
1 parent d719ee1 commit a2c330d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/node-labels.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ function resolveLabels (filepathsChanged) {
2525
}
2626

2727
function matchExclusiveSubSystem (filepathsChanged) {
28+
const isExclusive = filepathsChanged.every(matchesAnExclusiveLabel)
2829
const labels = matchSubSystemsByRegex(exclusiveLabelsMap, filepathsChanged)
29-
return labels.length === 1 ? labels : []
30+
return (isExclusive && labels.length === 1) ? labels : []
3031
}
3132

3233
function matchAllSubSystem (filepathsChanged) {
@@ -75,4 +76,8 @@ function withoutUndefinedValues (label) {
7576
return label !== undefined
7677
}
7778

79+
function matchesAnExclusiveLabel (filepath) {
80+
return mappedSubSystemForFile(exclusiveLabelsMap, filepath) !== undefined
81+
}
82+
7883
exports.resolveLabels = resolveLabels

test/node-labels.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ tap.test('no labels: when ./test/ and ./doc/ files has been changed', (t) => {
2727
t.end()
2828
})
2929

30+
// This ensures older mislabelling issues doesn't happen again
31+
// https://github.com/nodejs/node/pull/6432
32+
// https://github.com/nodejs/node/pull/6448
33+
tap.test('no labels: when ./test/ and ./lib/ files has been changed', (t) => {
34+
const labels = nodeLabels.resolveLabels([
35+
'lib/assert.js',
36+
'test/parallel/test-assert.js'
37+
])
38+
39+
t.same(labels, [])
40+
41+
t.end()
42+
})
43+
3044
tap.test('label: "doc" when only ./doc/ files has been changed', (t) => {
3145
const labels = nodeLabels.resolveLabels([
3246
'doc/api/fs.md',

0 commit comments

Comments
 (0)