fix: issue pagination/filtering

This commit is contained in:
Rhys Arkins 2018-12-19 15:31:20 +01:00
parent 820a8a8ab5
commit e0d7784ddb
2 changed files with 9 additions and 7 deletions

View file

@ -57,7 +57,7 @@ async function get(path, options, retries = 5) {
const linkHeader = parseLinkHeader(res.headers.link); const linkHeader = parseLinkHeader(res.headers.link);
if (linkHeader && linkHeader.next && linkHeader.last) { if (linkHeader && linkHeader.next && linkHeader.last) {
let lastPage = +linkHeader.last.page; let lastPage = +linkHeader.last.page;
if (!process.env.RENOVATE_PAGINATE_ALL) { if (!process.env.RENOVATE_PAGINATE_ALL && opts.paginate !== 'all') {
lastPage = Math.min(pageLimit, lastPage); lastPage = Math.min(pageLimit, lastPage);
} }
const pageNumbers = Array.from( const pageNumbers = Array.from(

View file

@ -624,18 +624,20 @@ async function getIssueList() {
const res = await get( const res = await get(
`repos/${config.parentRepo || `repos/${config.parentRepo ||
config.repository}/issues?creator=${renovateUsername}&state=all&per_page=100&sort=created&direction=asc`, config.repository}/issues?creator=${renovateUsername}&state=all&per_page=100&sort=created&direction=asc`,
{ paginate: true, useCache: false } { paginate: 'all', useCache: false }
); );
// istanbul ignore if // istanbul ignore if
if (!is.array(res.body)) { if (!is.array(res.body)) {
logger.warn({ responseBody: res.body }, 'Could not retrieve issue list'); logger.warn({ responseBody: res.body }, 'Could not retrieve issue list');
return []; return [];
} }
config.issueList = res.body.map(i => ({ config.issueList = res.body
number: i.number, .filter(issue => !issue.pull_request)
state: i.state, .map(i => ({
title: i.title, number: i.number,
})); state: i.state,
title: i.title,
}));
logger.debug('Retrieved ' + config.issueList.length + ' issues'); logger.debug('Retrieved ' + config.issueList.length + ' issues');
} }
return config.issueList; return config.issueList;