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 commitFiles from platforms #6701

Merged
merged 6 commits into from Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
136 changes: 0 additions & 136 deletions lib/platform/__snapshots__/index.spec.ts.snap
Expand Up @@ -2,142 +2,6 @@

exports[`platform escapes names 1`] = `"name [what]"`;

exports[`platform has a list of supported methods for azure 1`] = `
Array [
"addAssignees",
"addReviewers",
"commitFiles",
"createPr",
"deleteBranch",
"deleteLabel",
"ensureComment",
"ensureCommentRemoval",
"ensureIssue",
"ensureIssueClosing",
"findIssue",
"findPr",
"getBranchPr",
"getBranchStatus",
"getBranchStatusCheck",
"getIssueList",
"getPr",
"getPrBody",
"getPrFiles",
"getPrList",
"getRepoForceRebase",
"getRepos",
"getVulnerabilityAlerts",
"initPlatform",
"initRepo",
"mergePr",
"setBaseBranch",
"setBranchStatus",
"updatePr",
]
`;

exports[`platform has a list of supported methods for gitea 1`] = `
Array [
"addAssignees",
"addReviewers",
"commitFiles",
"createPr",
"deleteBranch",
"deleteLabel",
"ensureComment",
"ensureCommentRemoval",
"ensureIssue",
"ensureIssueClosing",
"findIssue",
"findPr",
"getBranchPr",
"getBranchStatus",
"getBranchStatusCheck",
"getIssueList",
"getPr",
"getPrBody",
"getPrFiles",
"getPrList",
"getRepoForceRebase",
"getRepos",
"getVulnerabilityAlerts",
"initPlatform",
"initRepo",
"mergePr",
"setBaseBranch",
"setBranchStatus",
"updatePr",
]
`;

exports[`platform has a list of supported methods for github 1`] = `
Array [
"addAssignees",
"addReviewers",
"commitFiles",
"createPr",
"deleteBranch",
"deleteLabel",
"ensureComment",
"ensureCommentRemoval",
"ensureIssue",
"ensureIssueClosing",
"findIssue",
"findPr",
"getBranchPr",
"getBranchStatus",
"getBranchStatusCheck",
"getIssueList",
"getPr",
"getPrBody",
"getPrFiles",
"getPrList",
"getRepoForceRebase",
"getRepos",
"getVulnerabilityAlerts",
"initPlatform",
"initRepo",
"mergePr",
"setBaseBranch",
"setBranchStatus",
"updatePr",
]
`;

exports[`platform has a list of supported methods for gitlab 1`] = `
Array [
"addAssignees",
"addReviewers",
"commitFiles",
"createPr",
"deleteBranch",
"deleteLabel",
"ensureComment",
"ensureCommentRemoval",
"ensureIssue",
"ensureIssueClosing",
"findIssue",
"findPr",
"getBranchPr",
"getBranchStatus",
"getBranchStatusCheck",
"getIssueList",
"getPr",
"getPrBody",
"getPrFiles",
"getPrList",
"getRepoForceRebase",
"getRepos",
"getVulnerabilityAlerts",
"initPlatform",
"initRepo",
"mergePr",
"setBaseBranch",
"setBranchStatus",
"updatePr",
]
`;

exports[`platform initializes 1`] = `
Object {
"endpoint": "https://api.bitbucket.org/",
Expand Down
13 changes: 0 additions & 13 deletions lib/platform/azure/index.ts
Expand Up @@ -19,7 +19,6 @@ import { sanitize } from '../../util/sanitize';
import { ensureTrailingSlash } from '../../util/url';
import {
BranchStatusConfig,
CommitFilesConfig,
CreatePRConfig,
EnsureCommentConfig,
EnsureCommentRemovalConfig,
Expand Down Expand Up @@ -331,18 +330,6 @@ export /* istanbul ignore next */ async function deleteBranch(
}
}

export /* istanbul ignore next */ function commitFiles({
branchName,
files,
message,
}: CommitFilesConfig): Promise<string | null> {
return git.commitFiles({
branchName,
files,
message,
});
}

export async function getBranchStatusCheck(
branchName: string,
context: string
Expand Down
18 changes: 0 additions & 18 deletions lib/platform/bitbucket/__snapshots__/index.spec.ts.snap
Expand Up @@ -64,24 +64,6 @@ Array [
]
`;

exports[`platform/bitbucket commitFiles() sends to gitFs 1`] = `undefined`;

exports[`platform/bitbucket commitFiles() sends to gitFs 2`] = `
Array [
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"authorization": "Basic YWJjOjEyMw==",
"host": "api.bitbucket.org",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.bitbucket.org/2.0/repositories/some/repo",
},
]
`;

exports[`platform/bitbucket createPr() posts PR 1`] = `
Array [
Object {
Expand Down
13 changes: 0 additions & 13 deletions lib/platform/bitbucket/index.spec.ts
Expand Up @@ -807,19 +807,6 @@ describe('platform/bitbucket', () => {
});
});

describe('commitFiles()', () => {
it('sends to gitFs', async () => {
await initRepoMock();
const res = await bitbucket.commitFiles({
branchName: 'test',
files: [],
message: 'message',
});
expect(res).toMatchSnapshot();
expect(httpMock.getTrace()).toMatchSnapshot();
});
});

describe('getVulnerabilityAlerts()', () => {
it('returns empty array', async () => {
expect(await bitbucket.getVulnerabilityAlerts()).toEqual([]);
Expand Down
8 changes: 0 additions & 8 deletions lib/platform/bitbucket/index.ts
Expand Up @@ -16,7 +16,6 @@ import { BitbucketHttp, setBaseUrl } from '../../util/http/bitbucket';
import { sanitize } from '../../util/sanitize';
import {
BranchStatusConfig,
CommitFilesConfig,
CreatePRConfig,
EnsureCommentConfig,
EnsureCommentRemovalConfig,
Expand Down Expand Up @@ -250,13 +249,6 @@ export async function deleteBranch(
return git.deleteBranch(branchName);
}

// istanbul ignore next
export function commitFiles(
commitFilesConfig: CommitFilesConfig
): Promise<string | null> {
return git.commitFiles(commitFilesConfig);
}

async function isPrConflicted(prNo: number): Promise<boolean> {
const diff = (
await bitbucketHttp.get(
Expand Down
2 changes: 1 addition & 1 deletion lib/platform/common.ts
Expand Up @@ -215,7 +215,7 @@ export interface Platform {
deleteBranch(branchName: string, closePr?: boolean): Promise<void>;
ensureComment(ensureComment: EnsureCommentConfig): Promise<boolean>;
setBaseBranch(baseBranch?: string): Promise<string>;
commitFiles(commitFile: CommitFilesConfig): Promise<string | null>;
commitFiles?(commitFile: CommitFilesConfig): Promise<string | null>;
getPr(number: number): Promise<Pr>;
findPr(findPRConfig: FindPRConfig): Promise<Pr>;
getBranchStatus(
Expand Down
27 changes: 1 addition & 26 deletions lib/platform/gitea/index.spec.ts
@@ -1,11 +1,4 @@
import {
BranchStatusConfig,
CommitFilesConfig,
File,
Platform,
RepoConfig,
RepoParams,
} from '..';
import { BranchStatusConfig, Platform, RepoConfig, RepoParams } from '..';
import { partial } from '../../../test/util';
import {
REPOSITORY_ACCESS_FORBIDDEN,
Expand Down Expand Up @@ -1336,24 +1329,6 @@ describe('platform/gitea', () => {
});
});

describe('commitFiles', () => {
it('should propagate call to storage class with default parent branch', async () => {
const commitConfig: CommitFilesConfig = {
branchName: 'some-branch',
files: [partial<File>({})],
message: 'some-message',
};

await initFakeRepo();
await gitea.commitFiles(commitConfig);

expect(gitvcs.commitFiles).toHaveBeenCalledTimes(1);
expect(gitvcs.commitFiles).toHaveBeenCalledWith({
...commitConfig,
});
});
});

describe('getPrBody', () => {
it('should truncate body to 1000000 characters', () => {
const excessiveBody = '*'.repeat(1000001);
Expand Down
6 changes: 0 additions & 6 deletions lib/platform/gitea/index.ts
Expand Up @@ -21,7 +21,6 @@ import { sanitize } from '../../util/sanitize';
import { ensureTrailingSlash } from '../../util/url';
import {
BranchStatusConfig,
CommitFilesConfig,
CreatePRConfig,
EnsureCommentConfig,
EnsureCommentRemovalConfig,
Expand Down Expand Up @@ -850,10 +849,6 @@ const platform: Platform = {
return Promise.resolve();
},

commitFiles(commitFilesConfig: CommitFilesConfig): Promise<string | null> {
return git.commitFiles(commitFilesConfig);
},

getPrBody(prBody: string): string {
return smartTruncate(prBody, 1000000);
},
Expand All @@ -866,7 +861,6 @@ const platform: Platform = {
export const {
addAssignees,
addReviewers,
commitFiles,
createPr,
deleteBranch,
deleteLabel,
Expand Down
8 changes: 0 additions & 8 deletions lib/platform/github/index.ts
Expand Up @@ -31,7 +31,6 @@ import { sanitize } from '../../util/sanitize';
import { ensureTrailingSlash } from '../../util/url';
import {
BranchStatusConfig,
CommitFilesConfig,
CreatePRConfig,
EnsureCommentConfig,
EnsureCommentRemovalConfig,
Expand Down Expand Up @@ -494,13 +493,6 @@ export function deleteBranch(
return git.deleteBranch(branchName);
}

// istanbul ignore next
export function commitFiles(
commitFilesConfig: CommitFilesConfig
): Promise<string | null> {
return git.commitFiles(commitFilesConfig);
}

async function getClosedPrs(): Promise<PrList> {
if (!config.closedPrList) {
config.closedPrList = {};
Expand Down
16 changes: 0 additions & 16 deletions lib/platform/gitlab/__snapshots__/index.spec.ts.snap
Expand Up @@ -148,22 +148,6 @@ Array [

exports[`platform/gitlab addReviewers(issueNo, reviewers) should add the given reviewers to the PR 1`] = `Array []`;

exports[`platform/gitlab commitFiles() sends to gitFs 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"host": "gitlab.com",
"private-token": "abc123",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://gitlab.com/api/v4/projects/some%2Frepo",
},
]
`;

exports[`platform/gitlab createPr(branchName, title, body) auto-accepts the MR when requested 1`] = `
Array [
Object {
Expand Down
12 changes: 0 additions & 12 deletions lib/platform/gitlab/index.spec.ts
Expand Up @@ -1171,18 +1171,6 @@ These updates have all been created already. Click a checkbox below to force a r
expect(gitlab.getPrBody(prBody)).toMatchSnapshot();
});
});
describe('commitFiles()', () => {
it('sends to gitFs', async () => {
expect.assertions(1);
await initRepo();
await gitlab.commitFiles({
branchName: 'some-branch',
files: [{ name: 'SomeFile', contents: 'Some Content' }],
message: '',
});
expect(httpMock.getTrace()).toMatchSnapshot();
});
});
describe('getVulnerabilityAlerts()', () => {
it('returns empty', async () => {
const res = await gitlab.getVulnerabilityAlerts();
Expand Down
8 changes: 0 additions & 8 deletions lib/platform/gitlab/index.ts
Expand Up @@ -26,7 +26,6 @@ import { sanitize } from '../../util/sanitize';
import { ensureTrailingSlash } from '../../util/url';
import {
BranchStatusConfig,
CommitFilesConfig,
CreatePRConfig,
EnsureCommentConfig,
EnsureCommentRemovalConfig,
Expand Down Expand Up @@ -590,13 +589,6 @@ export async function getBranchPr(branchName: string): Promise<Pr> {
return getPr(pr.iid);
}

// istanbul ignore next
export function commitFiles(
commitFilesConfig: CommitFilesConfig
): Promise<string | null> {
return git.commitFiles(commitFilesConfig);
}

export async function deleteBranch(
branchName: string,
shouldClosePr = false
Expand Down