Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

labels: fix labeling for non-subsystem API docs #126

Merged
merged 1 commit into from
Feb 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/node-labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,27 @@ 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') &&
labels.length > 2) {
const nonDocLabels = labels.filter((val) => {
return val !== 'doc'
})
if (hasAllSubsystems(nonDocLabels)) {
if (hasAllSubsystems(nonDocLabels) || hasAllDocChanges(filepathsChanged)) {
labels = ['doc']
} else {
labels = []
Expand Down
11 changes: 11 additions & 0 deletions test/unit/node-labels.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,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()
})