mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
feat(github): rest fallback for GHE issue retrieval
Falls back to REST api for issues retrieval if GHE version is < 2.17.0
This commit is contained in:
parent
01548e2348
commit
154a8ddc2e
1 changed files with 33 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
const is = require('@sindresorhus/is');
|
const is = require('@sindresorhus/is');
|
||||||
const delay = require('delay');
|
const delay = require('delay');
|
||||||
|
const semver = require('semver');
|
||||||
const URL = require('url');
|
const URL = require('url');
|
||||||
|
|
||||||
const get = require('./gh-got-wrapper');
|
const get = require('./gh-got-wrapper');
|
||||||
|
@ -177,6 +178,8 @@ async function initRepo({
|
||||||
try {
|
try {
|
||||||
res = await get(`repos/${repository}`);
|
res = await get(`repos/${repository}`);
|
||||||
logger.trace({ repositoryDetails: res.body }, 'Repository details');
|
logger.trace({ repositoryDetails: res.body }, 'Repository details');
|
||||||
|
config.enterpriseVersion =
|
||||||
|
res.headers && res.headers['x-github-enterprise-version'];
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (res.body.fork && !includeForks) {
|
if (res.body.fork && !includeForks) {
|
||||||
try {
|
try {
|
||||||
|
@ -696,10 +699,39 @@ async function getGraphqlIssues(afterCursor = null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// istanbul ignore next
|
||||||
|
async function getRestIssues() {
|
||||||
|
logger.debug('Retrieving issueList');
|
||||||
|
const res = await get(
|
||||||
|
`repos/${config.repository}/issues?creator=${config.renovateUsername}&state=all&per_page=100&sort=created&direction=asc`,
|
||||||
|
{ paginate: 'all', useCache: false }
|
||||||
|
);
|
||||||
|
// istanbul ignore if
|
||||||
|
if (!is.array(res.body)) {
|
||||||
|
logger.warn({ responseBody: res.body }, 'Could not retrieve issue list');
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return res.body
|
||||||
|
.filter(issue => !issue.pull_request)
|
||||||
|
.map(i => ({
|
||||||
|
number: i.number,
|
||||||
|
state: i.state,
|
||||||
|
title: i.title,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
async function getIssueList() {
|
async function getIssueList() {
|
||||||
if (!config.issueList) {
|
if (!config.issueList) {
|
||||||
logger.debug('Retrieving issueList');
|
logger.debug('Retrieving issueList');
|
||||||
|
const filterBySupportMinimumGheVersion = '2.17.0';
|
||||||
|
// istanbul ignore if
|
||||||
|
if (
|
||||||
|
config.enterpriseVersion &&
|
||||||
|
semver.lt(config.enterpriseVersion, filterBySupportMinimumGheVersion)
|
||||||
|
) {
|
||||||
|
config.issueList = await getRestIssues();
|
||||||
|
return config.issueList;
|
||||||
|
}
|
||||||
let [success, issues, cursor] = await getGraphqlIssues();
|
let [success, issues, cursor] = await getGraphqlIssues();
|
||||||
config.issueList = [];
|
config.issueList = [];
|
||||||
while (success) {
|
while (success) {
|
||||||
|
|
Loading…
Reference in a new issue