Skip to content

Commit

Permalink
Fix for bad node core PR exclusive labels.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
phillipj committed Apr 28, 2016
1 parent d719ee1 commit 95ec68a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/node-labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ function resolveLabels (filepathsChanged) {
}

function matchExclusiveSubSystem (filepathsChanged) {
const isExclusive = filepathsChanged.every(matchesAnExclusiveLabel)
const labels = matchSubSystemsByRegex(exclusiveLabelsMap, filepathsChanged)
return labels.length === 1 ? labels : []
return (isExclusive && labels.length === 1) ? labels : []
}

function matchAllSubSystem (filepathsChanged) {
Expand Down Expand Up @@ -75,4 +76,8 @@ function withoutUndefinedValues (label) {
return label !== undefined
}

function matchesAnExclusiveLabel (filepath) {
return mappedSubSystemForFile(exclusiveLabelsMap, filepath) !== undefined
}

exports.resolveLabels = resolveLabels
14 changes: 14 additions & 0 deletions test/node-labels.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ tap.test('no labels: when ./test/ and ./doc/ files has been changed', (t) => {
t.end()
})

// This ensures older mislabelling issues doesn't happen again
// https://github.com/nodejs/node/pull/6432
// https://github.com/nodejs/node/pull/6448
tap.test('no labels: when ./test/ and ./lib/ files has been changed', (t) => {
const labels = nodeLabels.resolveLabels([
'lib/assert.js',
'test/parallel/test-assert.js'
])

t.same(labels, [])

t.end()
})

tap.test('label: "doc" when only ./doc/ files has been changed', (t) => {
const labels = nodeLabels.resolveLabels([
'doc/api/fs.md',
Expand Down

0 comments on commit 95ec68a

Please sign in to comment.