Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
attempt-backport: enable label removal for Current lines
Refs: #77
PR-URL: #90
  • Loading branch information
Fishrock123 committed Nov 16, 2016
commit 323215e92b75e472f5a9e9fb6bf0d417fa3e817b
25 changes: 25 additions & 0 deletions lib/node-repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,30 @@ function updatePrWithLabels (options, labels) {
})
}

function removeLabelFromPR (options, label) {
// no need to request github if we didn't resolve a label
if (!label) {
return
}

options.logger.debug('Trying to remove label: ' + label)

githubClient.issues.removeLabel({
user: options.owner,
repo: options.repo,
number: options.prId,
name: label
}, (err) => {
if (err) {
if (err.code === 404) return options.logger.info('Label to remove did not exist, bailing ' + label)

return options.logger.error(err, 'Error while removing a label')
}

options.logger.info('Removed a label ' + label)
})
}

function fetchExistingLabels (options, cb) {
const cacheKey = `${options.owner}:${options.repo}`

Expand Down Expand Up @@ -93,6 +117,7 @@ function itemsInCommon (arr1, arr2) {
return arr1.filter((item) => arr2.indexOf(item) !== -1)
}

exports.removeLabelFromPR = removeLabelFromPR
exports.updatePrWithLabels = updatePrWithLabels
exports.resolveLabelsThenUpdatePr = deferredResolveLabelsThenUpdatePr

Expand Down
10 changes: 8 additions & 2 deletions scripts/attempt-backport.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
const child_process = require('child_process')
const debug = require('debug')('attempt-backport')
const request = require('request')
const updatePrWithLabels = require('../lib/node-repo').updatePrWithLabels
const node_repo = require('../lib/node-repo')
const updatePrWithLabels = node_repo.updatePrWithLabels
const removeLabelFromPR = node_repo.removeLabelFromPR

const enabledRepos = ['node']
const queue = []
Expand Down Expand Up @@ -193,7 +195,11 @@ function attemptBackport(options, version, isLTS, cb) {
options.logger.debug(`attempting a backport to v${version}...`)
const cp = wrapCP('git', ['am'], { stdio: 'pipe' }, function done() {
// Success!
if (isLTS) updatePrWithLabels(options, [`lts-watch-v${version}.x`])
if (isLTS) {
updatePrWithLabels(options, [`lts-watch-v${version}.x`])
} else {
removeLabelFromPR(options, `dont-land-on-v${version}.x`)
}

setImmediate(() => {
options.logger.debug(`backport to v${version} successful`)
Expand Down