Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
refactor: remove unnecessary cleanRepo() (#6671)
  • Loading branch information
rarkins committed Jul 4, 2020
1 parent 78e319f commit 1e0c759
Show file tree
Hide file tree
Showing 17 changed files with 1 addition and 107 deletions.
4 changes: 0 additions & 4 deletions lib/platform/__snapshots__/index.spec.ts.snap
Expand Up @@ -7,7 +7,6 @@ Array [
"addAssignees",
"addReviewers",
"branchExists",
"cleanRepo",
"commitFiles",
"createPr",
"deleteBranch",
Expand Down Expand Up @@ -52,7 +51,6 @@ Array [
"addAssignees",
"addReviewers",
"branchExists",
"cleanRepo",
"commitFiles",
"createPr",
"deleteBranch",
Expand Down Expand Up @@ -97,7 +95,6 @@ Array [
"addAssignees",
"addReviewers",
"branchExists",
"cleanRepo",
"commitFiles",
"createPr",
"deleteBranch",
Expand Down Expand Up @@ -142,7 +139,6 @@ Array [
"addAssignees",
"addReviewers",
"branchExists",
"cleanRepo",
"commitFiles",
"createPr",
"deleteBranch",
Expand Down
10 changes: 0 additions & 10 deletions lib/platform/azure/index.spec.ts
Expand Up @@ -35,10 +35,6 @@ describe('platform/azure', () => {
});
});

afterEach(async () => {
await azure.cleanRepo();
});

// do we need the args?
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function getRepos(_token: string, _endpoint: string) {
Expand Down Expand Up @@ -170,12 +166,6 @@ describe('platform/azure', () => {
});
});

describe('cleanRepo()', () => {
it('exists', async () => {
await expect(azure.cleanRepo()).resolves.not.toThrow();
});
});

describe('initRepo', () => {
it(`should initialise the config for a repo`, async () => {
const config = await initRepo({
Expand Down
6 changes: 0 additions & 6 deletions lib/platform/azure/index.ts
Expand Up @@ -767,9 +767,3 @@ export /* istanbul ignore next */ async function deleteLabel(
export function getVulnerabilityAlerts(): Promise<VulnerabilityAlert[]> {
return Promise.resolve([]);
}

export function cleanRepo(): Promise<void> {
git.cleanRepo();
config = {} as any;
return Promise.resolve();
}
4 changes: 0 additions & 4 deletions lib/platform/bitbucket-server/index.spec.ts
Expand Up @@ -197,10 +197,6 @@ describe('platform/bitbucket-server', () => {
});
});

afterEach(async () => {
await bitbucket.cleanRepo();
});

describe('initPlatform()', () => {
it('should throw if no endpoint', () => {
expect.assertions(1);
Expand Down
7 changes: 0 additions & 7 deletions lib/platform/bitbucket-server/index.ts
Expand Up @@ -105,13 +105,6 @@ export async function getRepos(): Promise<string[]> {
}
}

export function cleanRepo(): Promise<void> {
logger.debug(`cleanRepo()`);
git.cleanRepo();
config = {} as any;
return Promise.resolve();
}

// Initialize GitLab by getting base branch
export async function initRepo({
repository,
Expand Down
4 changes: 0 additions & 4 deletions lib/platform/bitbucket/index.spec.ts
Expand Up @@ -74,10 +74,6 @@ describe('platform/bitbucket', () => {
setBaseUrl(baseUrl);
});

afterEach(async () => {
await bitbucket.cleanRepo();
});

async function initRepoMock(
config?: Partial<RepoParams>,
repoResp?: any
Expand Down
8 changes: 0 additions & 8 deletions lib/platform/bitbucket/index.ts
Expand Up @@ -870,14 +870,6 @@ export async function mergePr(
return true;
}

// Pull Request

export function cleanRepo(): Promise<void> {
git.cleanRepo();
config = {} as any;
return Promise.resolve();
}

export function getVulnerabilityAlerts(): Promise<VulnerabilityAlert[]> {
return Promise.resolve([]);
}
1 change: 0 additions & 1 deletion lib/platform/common.ts
Expand Up @@ -190,7 +190,6 @@ export interface Platform {
getCommitMessages(): Promise<string[]>;
setBranchPrefix(branchPrefix: string): Promise<void>;
initRepo(config: RepoParams): Promise<RepoConfig>;
cleanRepo(): Promise<void>;
getPrList(): Promise<Pr[]>;
getPrFiles(pr: Pr): Promise<string[]>;
getAllRenovateBranches(branchPrefix: string): Promise<string[]>;
Expand Down
13 changes: 0 additions & 13 deletions lib/platform/gitea/index.spec.ts
Expand Up @@ -328,19 +328,6 @@ describe('platform/gitea', () => {
});
});

describe('cleanRepo', () => {
it('does not throw an error with uninitialized repo', async () => {
await gitea.cleanRepo();
expect(gitvcs.cleanRepo).toHaveBeenCalledTimes(1);
});

it('propagates call to storage class with initialized repo', async () => {
await initFakeRepo();
await gitea.cleanRepo();
expect(gitvcs.cleanRepo).toHaveBeenCalledTimes(1);
});
});

describe('setBranchStatus', () => {
const setBranchStatus = async (bsc?: Partial<BranchStatusConfig>) => {
await initFakeRepo();
Expand Down
7 changes: 0 additions & 7 deletions lib/platform/gitea/index.ts
Expand Up @@ -362,12 +362,6 @@ const platform: Platform = {
}
},

cleanRepo(): Promise<void> {
git.cleanRepo();
config = {} as any;
return Promise.resolve();
},

async setBranchStatus({
branchName,
context,
Expand Down Expand Up @@ -913,7 +907,6 @@ export const {
addAssignees,
addReviewers,
branchExists,
cleanRepo,
commitFiles,
createPr,
deleteBranch,
Expand Down
11 changes: 1 addition & 10 deletions lib/platform/github/index.ts
Expand Up @@ -149,13 +149,6 @@ export async function getRepos(): Promise<string[]> {
}
}

export function cleanRepo(): Promise<void> {
git.cleanRepo();
// In theory most of this isn't necessary. In practice..
config = {} as any;
return Promise.resolve();
}

async function getBranchProtection(
branchName: string
): Promise<BranchProtection> {
Expand Down Expand Up @@ -208,7 +201,7 @@ export async function initRepo({
}: RepoParams): Promise<RepoConfig> {
logger.debug(`initRepo("${repository}")`);
// config is used by the platform api itself, not necessary for the app layer to know
await cleanRepo();
config = { localDir, repository } as any;
// istanbul ignore if
if (endpoint) {
// Necessary for Renovate Pro - do not remove
Expand All @@ -222,8 +215,6 @@ export async function initRepo({
});
config.isGhe = URL.parse(defaults.endpoint).host !== 'api.github.com';
config.renovateUsername = renovateUsername;
config.localDir = localDir;
config.repository = repository;
[config.repositoryOwner, config.repositoryName] = repository.split('/');
let res;
try {
Expand Down
2 changes: 0 additions & 2 deletions lib/platform/gitlab/__snapshots__/index.spec.ts.snap
Expand Up @@ -175,8 +175,6 @@ Array [
]
`;

exports[`platform/gitlab cleanRepo() exists 1`] = `undefined`;

exports[`platform/gitlab commitFiles() sends to gitFs 1`] = `
Array [
Object {
Expand Down
9 changes: 0 additions & 9 deletions lib/platform/gitlab/index.spec.ts
Expand Up @@ -45,10 +45,6 @@ describe('platform/gitlab', () => {
httpMock.setup();
});

afterEach(async () => {
await gitlab.cleanRepo();
});

describe('initPlatform()', () => {
it(`should throw if no token`, async () => {
await expect(gitlab.initPlatform({} as any)).rejects.toThrow();
Expand Down Expand Up @@ -165,11 +161,6 @@ describe('platform/gitlab', () => {
expect(httpMock.getTrace()).toMatchSnapshot();
});
});
describe('cleanRepo()', () => {
it('exists', async () => {
expect(await gitlab.cleanRepo()).toMatchSnapshot();
});
});

describe('initRepo', () => {
it(`should throw error if disabled in renovate.json`, async () => {
Expand Down
7 changes: 0 additions & 7 deletions lib/platform/gitlab/index.ts
Expand Up @@ -138,13 +138,6 @@ function urlEscape(str: string): string {
return str ? str.replace(/\//g, '%2F') : str;
}

export function cleanRepo(): Promise<void> {
git.cleanRepo();
// In theory most of this isn't necessary. In practice..
config = {} as any;
return Promise.resolve();
}

// Initialize GitLab by getting base branch
export async function initRepo({
repository,
Expand Down
1 change: 0 additions & 1 deletion lib/util/git/index.spec.ts
Expand Up @@ -60,7 +60,6 @@ describe('platform/git', () => {
afterEach(async () => {
await tmpDir.cleanup();
await origin.cleanup();
git.cleanRepo();
});

afterAll(async () => {
Expand Down
12 changes: 0 additions & 12 deletions lib/util/git/index.ts
Expand Up @@ -146,19 +146,7 @@ export async function getSubmodules(): Promise<string[]> {
.filter((_e: string, i: number) => i % 2);
}

export function isInitialized(): boolean {
return !!git;
}

export function cleanRepo(): void {
if (isInitialized()) {
// no-op
}
}

export async function initRepo(args: StorageConfig): Promise<void> {
cleanRepo();

config = { ...args } as any;

config.branchExists = {};
Expand Down
2 changes: 0 additions & 2 deletions lib/workers/repository/index.ts
@@ -1,7 +1,6 @@
import fs from 'fs-extra';
import { RenovateConfig } from '../../config';
import { logger, setMeta } from '../../logger';
import { platform } from '../../platform';
import { deleteLocalFile } from '../../util/fs';
import { addSplit, getSplits, splitInit } from '../../util/split';
import handleError from './error';
Expand Down Expand Up @@ -51,7 +50,6 @@ export async function renovateRepository(
const errorRes = await handleError(config, err);
repoResult = processResult(config, errorRes);
}
await platform.cleanRepo();
if (config.localDir && !config.persistRepoData) {
await deleteLocalFile('.');
}
Expand Down

0 comments on commit 1e0c759

Please sign in to comment.