From 5bd2d42d5a59e41bb7ec44a89cbbb4fc9bafeb8d Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 14 May 2020 12:20:24 +0200 Subject: [PATCH] =?UTF-8?q?fix(platform):=20don=E2=80=99t=20pass=20parentB?= =?UTF-8?q?ranch=20to=20platform=20commitFilesToBranch=20(#6227)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/platform/azure/index.ts | 2 -- lib/platform/bitbucket-server/index.ts | 3 --- lib/platform/bitbucket/index.ts | 2 -- lib/platform/common.ts | 1 - lib/platform/git/storage.spec.ts | 16 +--------------- lib/platform/git/storage.ts | 7 +++++-- lib/platform/gitea/index.spec.ts | 16 ---------------- lib/platform/gitea/index.ts | 2 -- lib/platform/github/index.ts | 2 -- lib/platform/gitlab/index.ts | 2 -- .../branch/__snapshots__/commit.spec.ts.snap | 1 - lib/workers/branch/commit.ts | 1 - 12 files changed, 6 insertions(+), 49 deletions(-) diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index 52414ad774..8b98d93bf6 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -383,13 +383,11 @@ export /* istanbul ignore next */ function commitFilesToBranch({ branchName, files, message, - parentBranch = config.baseBranch, }: CommitFilesConfig): Promise<string | null> { return config.storage.commitFilesToBranch({ branchName, files, message, - parentBranch, }); } diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts index ca495e9c05..f5d83c27ae 100644 --- a/lib/platform/bitbucket-server/index.ts +++ b/lib/platform/bitbucket-server/index.ts @@ -430,7 +430,6 @@ export async function commitFilesToBranch({ branchName, files, message, - parentBranch = config.baseBranch, }: CommitFilesConfig): Promise<string | null> { logger.debug( `commitFilesToBranch(${JSON.stringify( @@ -438,7 +437,6 @@ export async function commitFilesToBranch({ branchName, filesLength: files.length, message, - parentBranch, }, null, 2 @@ -448,7 +446,6 @@ export async function commitFilesToBranch({ branchName, files, message, - parentBranch, }); // wait for pr change propagation diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index bba4830baf..2ec87005bd 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -292,13 +292,11 @@ export function commitFilesToBranch({ branchName, files, message, - parentBranch = config.baseBranch, }: CommitFilesConfig): Promise<string | null> { return config.storage.commitFilesToBranch({ branchName, files, message, - parentBranch, }); } diff --git a/lib/platform/common.ts b/lib/platform/common.ts index 38bc903153..a270c2383c 100644 --- a/lib/platform/common.ts +++ b/lib/platform/common.ts @@ -27,7 +27,6 @@ export type CommitFilesConfig = { branchName: string; files: File[]; message: string; - parentBranch?: string; }; export interface GotApiOptions { diff --git a/lib/platform/git/storage.spec.ts b/lib/platform/git/storage.spec.ts index 2a299e636b..01a035519d 100644 --- a/lib/platform/git/storage.spec.ts +++ b/lib/platform/git/storage.spec.ts @@ -162,20 +162,6 @@ describe('platform/git/storage', () => { it('should throw if branch merge throws', async () => { await expect(git.mergeBranch('not_found')).rejects.toThrow(); }); - it('should throw if branch merge is stale', async () => { - expect.assertions(1); - await git.setBranchPrefix('renovate/'); - await git.commitFilesToBranch({ - branchName: 'test', - files: [{ name: 'some-new-file', contents: 'some new-contents' }], - message: 'test mesage', - parentBranch: 'renovate/past_branch', - }); - - await git.setBaseBranch('master'); - - await expect(git.mergeBranch('test')).rejects.toThrow(); - }); }); describe('deleteBranch(branchName)', () => { it('should send delete', async () => { @@ -209,7 +195,7 @@ describe('platform/git/storage', () => { ).rejects.toMatchSnapshot(); }); }); - describe('commitFilesToBranch({branchName, files, message, parentBranch})', () => { + describe('commitFilesToBranch({branchName, files, message})', () => { it('creates file', async () => { const file = { name: 'some-new-file', diff --git a/lib/platform/git/storage.ts b/lib/platform/git/storage.ts index fe4838b3db..19fe8d6692 100644 --- a/lib/platform/git/storage.ts +++ b/lib/platform/git/storage.ts @@ -468,13 +468,16 @@ export class Storage { branchName, files, message, - parentBranch = this._config.baseBranch, }: CommitFilesConfig): Promise<string | null> { logger.debug(`Committing files to branch ${branchName}`); try { await this._git.reset('hard'); await this._git.raw(['clean', '-fd']); - await this._git.checkout(['-B', branchName, 'origin/' + parentBranch]); + await this._git.checkout([ + '-B', + branchName, + 'origin/' + this._config.baseBranch, + ]); const fileNames = []; const deleted = []; for (const file of files) { diff --git a/lib/platform/gitea/index.spec.ts b/lib/platform/gitea/index.spec.ts index 1ab1a02d09..e9724382eb 100644 --- a/lib/platform/gitea/index.spec.ts +++ b/lib/platform/gitea/index.spec.ts @@ -1453,24 +1453,8 @@ index 0000000..2173594 expect(gsmCommitFilesToBranch).toHaveBeenCalledTimes(1); expect(gsmCommitFilesToBranch).toHaveBeenCalledWith({ ...commitConfig, - parentBranch: mockRepo.default_branch, }); }); - - it('should propagate call to storage class with custom parent branch', async () => { - const commitConfig: CommitFilesConfig = { - branchName: 'some-branch', - files: [partial<File>({})], - message: 'some-message', - parentBranch: 'some-parent-branch', - }; - - await initFakeRepo(); - await gitea.commitFilesToBranch(commitConfig); - - expect(gsmCommitFilesToBranch).toHaveBeenCalledTimes(1); - expect(gsmCommitFilesToBranch).toHaveBeenCalledWith(commitConfig); - }); }); describe('getPrBody', () => { diff --git a/lib/platform/gitea/index.ts b/lib/platform/gitea/index.ts index bc47b23f13..a3c70bcb10 100644 --- a/lib/platform/gitea/index.ts +++ b/lib/platform/gitea/index.ts @@ -891,13 +891,11 @@ const platform: Platform = { branchName, files, message, - parentBranch = config.baseBranch, }: CommitFilesConfig): Promise<string | null> { return config.storage.commitFilesToBranch({ branchName, files, message, - parentBranch, }); }, diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 108fb64602..9187981ea8 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -558,13 +558,11 @@ export function commitFilesToBranch({ branchName, files, message, - parentBranch = config.baseBranch, }: CommitFilesConfig): Promise<string | null> { return config.storage.commitFilesToBranch({ branchName, files, message, - parentBranch, }); } diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index 2e0a380576..9208cfdf1a 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -591,13 +591,11 @@ export function commitFilesToBranch({ branchName, files, message, - parentBranch = config.baseBranch, }: CommitFilesConfig): Promise<string | null> { return config.storage.commitFilesToBranch({ branchName, files, message, - parentBranch, }); } diff --git a/lib/workers/branch/__snapshots__/commit.spec.ts.snap b/lib/workers/branch/__snapshots__/commit.spec.ts.snap index 8fe48a4992..7f4762af4e 100644 --- a/lib/workers/branch/__snapshots__/commit.spec.ts.snap +++ b/lib/workers/branch/__snapshots__/commit.spec.ts.snap @@ -12,7 +12,6 @@ Array [ }, ], "message": "some commit message", - "parentBranch": undefined, }, ], ] diff --git a/lib/workers/branch/commit.ts b/lib/workers/branch/commit.ts index 0d8418ffbf..86f71984d1 100644 --- a/lib/workers/branch/commit.ts +++ b/lib/workers/branch/commit.ts @@ -37,6 +37,5 @@ export async function commitFilesToBranch( branchName: config.branchName, files: updatedFiles, message: config.commitMessage, - parentBranch: config.baseBranch || undefined, }); } -- GitLab