lib/pullRequests.js
function populateLabelsForPR(pr) {
  print(['Get labels for PR ', clc.yellow.bold(`${pr.head.user.login}/${pr.head.repo.name}#${pr.number}`)], debug);
  return new Promise((resolve) => {
    github.issues.getIssueLabels({
      user: pr.base.user.login,
      repo: pr.base.repo.name,
      number: pr.number
    }, function (err, labels) {
      if (err && debug) {
        print(['Error fetching labels for PR ', clc.red.bold`${pr.base.user.login}/${pr.base.repo.name}#${pr.number}`], debug);
      }
      if (labels && labels.length > 0) {
        pr.labels = labels.map((label) => {
          return {
            name: label.name,
            color: label.color
          };
        });
      }
      return resolve(pr);
    });
  });
}
function populateLabelsForPR(pr) {
  print(['Get labels for PR ', clc.yellow.bold(`${pr.head.user.login}/${pr.head.repo.name}#${pr.number}`)], debug);
  return new Promise((resolve) => {
    github.issues.getIssueLabels({
      user: pr.base.user.login,
      repo: pr.base.repo.name,
      number: pr.number
    }, function (err, labels) {
      if (err && debug) {
        print(['Error fetching labels for PR ', clc.red.bold`${pr.base.user.login}/${pr.base.repo.name}#${pr.number}`], debug);
      }
      if (labels && labels.length > 0) {
        pr.labels = labels.map((label) => {
          return {
            name: label.name,
            color: label.color
          };
        });
      }
      return resolve(pr);
    });
  });
}
function populateLabelsForPR ( pr ) { print ( [ 'Get labels for PR ' , clc . yellow . bold ( ` ${ pr . head . user . login } ${ pr . head . repo . name } ${ pr . number } ` ) ] , debug ) ; return new Promise ( ( resolve ) => { github . issues . getIssueLabels ( { user : pr . base . user . login , repo : pr . base . repo . name , number : pr . number } , function ( err , labels ) { if ( err && debug ) { print ( [ 'Error fetching labels for PR ' , clc . red . bold ` ${ pr . base . user . login } ${ pr . base . repo . name } ${ pr . number } ` ] , debug ) ; } if ( labels && labels . length > 0 ) { pr . labels = labels . map ( ( label ) => { return { name : label . name , color : label . color } ; } ) ; } return resolve ( pr ) ; } ) ; } ) ; }
Fetch a list of labels for a single pull-request
@param  {Object}  pr Pull-request metadata
@return {Promise}    Resolves to an array of labels
Fetch a list of labels for a single pull - request