Skip to content

Commit

Permalink
attempt-backport: enable label removal for Current lines
Browse files Browse the repository at this point in the history
Refs: #77
PR-URL: #90
  • Loading branch information
Fishrock123 committed Nov 16, 2016
1 parent 3a4c594 commit 39cf0d7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
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

0 comments on commit 39cf0d7

Please sign in to comment.