Skip to content

Commit 0ffcbe5

Browse files
committed
labels: prevent deps from getting "lib / src" label
1 parent 4faa9b5 commit 0ffcbe5

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/node-labels.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ function matchSubSystemsByRegex (rxLabelsMap, filepathsChanged, limitLib) {
104104

105105
for (var i = 0; i < mappedSubSystems.length; ++i) {
106106
const mappedSubSystem = mappedSubSystems[i]
107-
if (limitLib && jsSubsystemList.includes(mappedSubSystem)) {
107+
const considerLimiting = hasJsSubsystemFilechanges(filepathsChanged) &&
108+
limitLib &&
109+
jsSubsystemList.includes(mappedSubSystem)
110+
111+
if (considerLimiting) {
108112
if (jsLabelCount.length >= 4) {
109113
for (const jsLabel of jsLabelCount) {
110114
delete map[jsLabel]
@@ -157,4 +161,8 @@ function matchesAnExclusiveLabel (filepath) {
157161
return mappedSubSystemsForFile(exclusiveLabelsMap, filepath) !== undefined
158162
}
159163

164+
function hasJsSubsystemFilechanges (filepaths) {
165+
return filepaths.some((filepath) => filepath.startsWith('lib/'))
166+
}
167+
160168
exports.resolveLabels = resolveLabels

test/node-labels.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,21 @@ tap.test('label: "lib / src" when 5 or more JS sub-systems have been changed', (
157157
t.end()
158158
})
159159

160+
// https://github.com/nodejs/node/pull/7488 wrongfully labelled with "lib / src"
161+
tap.test('label: not "lib / src" when only deps have been changed', (t) => {
162+
const labels = nodeLabels.resolveLabels([
163+
'deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden',
164+
'deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiteralsWide.golden',
165+
'deps/v8/test/cctest/interpreter/bytecode_expectations/AssignmentsInBinaryExpression.golden',
166+
'deps/v8/test/cctest/interpreter/bytecode_expectations/BasicBlockToBoolean.golden',
167+
'deps/v8/test/cctest/interpreter/bytecode_expectations/BasicLoops.golden'
168+
])
169+
170+
t.same(labels, ['v8'])
171+
172+
t.end()
173+
})
174+
160175
tap.test('label: "JS sub-systems when less than 5 sub-systems have changed', (t) => {
161176
const labels = nodeLabels.resolveLabels([
162177
'lib/assert.js',

0 commit comments

Comments
 (0)