mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
refactor(github): don’t try/catch getAllRenovateBranches
This commit is contained in:
parent
d336f35ebb
commit
ba12183626
1 changed files with 24 additions and 28 deletions
|
@ -404,34 +404,30 @@ async function branchExists(branchName) {
|
||||||
|
|
||||||
async function getAllRenovateBranches(branchPrefix) {
|
async function getAllRenovateBranches(branchPrefix) {
|
||||||
logger.trace('getAllRenovateBranches');
|
logger.trace('getAllRenovateBranches');
|
||||||
try {
|
const allBranches = (await get(
|
||||||
const allBranches = (await get(
|
`repos/${config.repository}/git/refs/heads/${branchPrefix}`,
|
||||||
`repos/${config.repository}/git/refs/heads/${branchPrefix}`,
|
{
|
||||||
{
|
paginate: true,
|
||||||
paginate: true,
|
}
|
||||||
}
|
)).body;
|
||||||
)).body;
|
return allBranches.reduce((arr, branch) => {
|
||||||
return allBranches.reduce((arr, branch) => {
|
if (branch.ref.startsWith(`refs/heads/${branchPrefix}`)) {
|
||||||
if (branch.ref.startsWith(`refs/heads/${branchPrefix}`)) {
|
arr.push(branch.ref.substring('refs/heads/'.length));
|
||||||
arr.push(branch.ref.substring('refs/heads/'.length));
|
}
|
||||||
}
|
if (
|
||||||
if (
|
branchPrefix.endsWith('/') &&
|
||||||
branchPrefix.endsWith('/') &&
|
branch.ref === `refs/heads/${branchPrefix.slice(0, -1)}`
|
||||||
branch.ref === `refs/heads/${branchPrefix.slice(0, -1)}`
|
) {
|
||||||
) {
|
logger.warn(
|
||||||
logger.warn(
|
`Pruning branch "${branchPrefix.slice(
|
||||||
`Pruning branch "${branchPrefix.slice(
|
0,
|
||||||
0,
|
-1
|
||||||
-1
|
)}" so that it does not block PRs`
|
||||||
)}" so that it does not block PRs`
|
);
|
||||||
);
|
arr.push(branch.ref.substring('refs/heads/'.length));
|
||||||
arr.push(branch.ref.substring('refs/heads/'.length));
|
}
|
||||||
}
|
return arr;
|
||||||
return arr;
|
}, []);
|
||||||
}, []);
|
|
||||||
} catch (err) /* istanbul ignore next */ {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function isBranchStale(branchName) {
|
async function isBranchStale(branchName) {
|
||||||
|
|
Loading…
Reference in a new issue