Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove branch functions from platform #6676

Merged
merged 9 commits into from Jul 4, 2020
5 changes: 2 additions & 3 deletions lib/manager/npm/post-update/index.ts
Expand Up @@ -12,11 +12,10 @@ import upath from 'upath';
import { SYSTEM_INSUFFICIENT_DISK_SPACE } from '../../../constants/error-messages';
import { id as npmId } from '../../../datasource/npm';
import { logger } from '../../../logger';
import { platform } from '../../../platform';
import { ExternalHostError } from '../../../types/errors/external-host-error';
import { getChildProcessEnv } from '../../../util/exec/env';
import { deleteLocalFile } from '../../../util/fs';
import { getFile, getRepoStatus } from '../../../util/git';
import { branchExists, getFile, getRepoStatus } from '../../../util/git';
import * as hostRules from '../../../util/host-rules';
import { PackageFile, PostUpdateConfig, Upgrade } from '../../common';
import * as lerna from './lerna';
Expand Down Expand Up @@ -347,7 +346,7 @@ export async function getAdditionalFiles(
if (
config.updateType === 'lockFileMaintenance' &&
config.reuseExistingBranch &&
(await platform.branchExists(config.branchName))
(await branchExists(config.branchName))
) {
logger.debug('Skipping lockFileMaintenance update');
return { artifactErrors, updatedArtifacts };
Expand Down
28 changes: 0 additions & 28 deletions lib/platform/__snapshots__/index.spec.ts.snap
Expand Up @@ -6,7 +6,6 @@ exports[`platform has a list of supported methods for azure 1`] = `
Array [
"addAssignees",
"addReviewers",
"branchExists",
"commitFiles",
"createPr",
"deleteBranch",
Expand All @@ -17,12 +16,9 @@ Array [
"ensureIssueClosing",
"findIssue",
"findPr",
"getAllRenovateBranches",
"getBranchLastCommitTime",
"getBranchPr",
"getBranchStatus",
"getBranchStatusCheck",
"getCommitMessages",
"getIssueList",
"getPr",
"getPrBody",
Expand All @@ -33,11 +29,8 @@ Array [
"getVulnerabilityAlerts",
"initPlatform",
"initRepo",
"isBranchStale",
"mergeBranch",
"mergePr",
"setBaseBranch",
"setBranchPrefix",
"setBranchStatus",
"updatePr",
]
Expand All @@ -47,7 +40,6 @@ exports[`platform has a list of supported methods for gitea 1`] = `
Array [
"addAssignees",
"addReviewers",
"branchExists",
"commitFiles",
"createPr",
"deleteBranch",
Expand All @@ -58,12 +50,9 @@ Array [
"ensureIssueClosing",
"findIssue",
"findPr",
"getAllRenovateBranches",
"getBranchLastCommitTime",
"getBranchPr",
"getBranchStatus",
"getBranchStatusCheck",
"getCommitMessages",
"getIssueList",
"getPr",
"getPrBody",
Expand All @@ -74,11 +63,8 @@ Array [
"getVulnerabilityAlerts",
"initPlatform",
"initRepo",
"isBranchStale",
"mergeBranch",
"mergePr",
"setBaseBranch",
"setBranchPrefix",
"setBranchStatus",
"updatePr",
]
Expand All @@ -88,7 +74,6 @@ exports[`platform has a list of supported methods for github 1`] = `
Array [
"addAssignees",
"addReviewers",
"branchExists",
"commitFiles",
"createPr",
"deleteBranch",
Expand All @@ -99,12 +84,9 @@ Array [
"ensureIssueClosing",
"findIssue",
"findPr",
"getAllRenovateBranches",
"getBranchLastCommitTime",
"getBranchPr",
"getBranchStatus",
"getBranchStatusCheck",
"getCommitMessages",
"getIssueList",
"getPr",
"getPrBody",
Expand All @@ -115,11 +97,8 @@ Array [
"getVulnerabilityAlerts",
"initPlatform",
"initRepo",
"isBranchStale",
"mergeBranch",
"mergePr",
"setBaseBranch",
"setBranchPrefix",
"setBranchStatus",
"updatePr",
]
Expand All @@ -129,7 +108,6 @@ exports[`platform has a list of supported methods for gitlab 1`] = `
Array [
"addAssignees",
"addReviewers",
"branchExists",
"commitFiles",
"createPr",
"deleteBranch",
Expand All @@ -140,12 +118,9 @@ Array [
"ensureIssueClosing",
"findIssue",
"findPr",
"getAllRenovateBranches",
"getBranchLastCommitTime",
"getBranchPr",
"getBranchStatus",
"getBranchStatusCheck",
"getCommitMessages",
"getIssueList",
"getPr",
"getPrBody",
Expand All @@ -156,11 +131,8 @@ Array [
"getVulnerabilityAlerts",
"initPlatform",
"initRepo",
"isBranchStale",
"mergeBranch",
"mergePr",
"setBaseBranch",
"setBranchPrefix",
"setBranchStatus",
"updatePr",
]
Expand Down
44 changes: 0 additions & 44 deletions lib/platform/azure/index.ts
Expand Up @@ -194,32 +194,6 @@ export /* istanbul ignore next */ async function setBaseBranch(
return baseBranchSha;
}

export /* istanbul ignore next */ function setBranchPrefix(
branchPrefix: string
): Promise<void> {
return git.setBranchPrefix(branchPrefix);
}

// Branch

export /* istanbul ignore next */ function branchExists(
branchName: string
): Promise<boolean> {
return git.branchExists(branchName);
}

export /* istanbul ignore next */ function getAllRenovateBranches(
branchPrefix: string
): Promise<string[]> {
return git.getAllRenovateBranches(branchPrefix);
}

export /* istanbul ignore next */ function isBranchStale(
branchName: string
): Promise<boolean> {
return git.isBranchStale(branchName);
}

// istanbul ignore next
async function abandonPr(prNo: number): Promise<void> {
logger.debug(`abandonPr(prNo)(${prNo})`);
Expand Down Expand Up @@ -357,18 +331,6 @@ export /* istanbul ignore next */ async function deleteBranch(
}
}

export /* istanbul ignore next */ function getBranchLastCommitTime(
branchName: string
): Promise<Date> {
return git.getBranchLastCommitTime(branchName);
}

export /* istanbul ignore next */ function mergeBranch(
branchName: string
): Promise<void> {
return git.mergeBranch(branchName);
}

export /* istanbul ignore next */ function commitFiles({
branchName,
files,
Expand All @@ -381,12 +343,6 @@ export /* istanbul ignore next */ function commitFiles({
});
}

export /* istanbul ignore next */ function getCommitMessages(): Promise<
string[]
> {
return git.getCommitMessages();
}

export async function getBranchStatusCheck(
branchName: string,
context: string
Expand Down