From 04ee279dcfb777f765ce0466acb58bbc53da8d9c Mon Sep 17 00:00:00 2001 From: Henrik Steen <henrist@henrist.net> Date: Tue, 30 Aug 2022 06:24:49 +0200 Subject: [PATCH] fix(repository/update): stopUpdating not working as expected (#17488) --- .../repository/update/branch/index.spec.ts | 37 ++++++++++++++++++- lib/workers/repository/update/branch/index.ts | 2 +- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lib/workers/repository/update/branch/index.spec.ts b/lib/workers/repository/update/branch/index.spec.ts index 75be7c8be6..2bded2d10f 100644 --- a/lib/workers/repository/update/branch/index.spec.ts +++ b/lib/workers/repository/update/branch/index.spec.ts @@ -1117,7 +1117,6 @@ describe('workers/repository/update/branch/index', () => { commit.commitFilesToBranch.mockResolvedValueOnce(null); const inconfig = { ...config, - dependencyDashboardChecks: { 'renovate/some-branch': 'true' }, updatedArtifacts: [{ type: 'deletion', path: 'dummy' }], } as BranchConfig; expect(await branchWorker.processBranch(inconfig)).toEqual({ @@ -1194,6 +1193,42 @@ describe('workers/repository/update/branch/index', () => { expect(commit.commitFilesToBranch).toHaveBeenCalled(); }); + it('updates branch if stopUpdatingLabel presents and dependency dashboard box checked', async () => { + getUpdated.getUpdatedPackageFiles.mockResolvedValueOnce( + partial<PackageFilesResult>({ + updatedPackageFiles: [partial<FileChange>({})], + artifactErrors: [], + updatedArtifacts: [], + }) + ); + npmPostExtract.getAdditionalFiles.mockResolvedValueOnce({ + artifactErrors: [], + updatedArtifacts: [partial<FileChange>({})], + } as WriteExistingFilesResult); + git.branchExists.mockReturnValue(true); + platform.getBranchPr.mockResolvedValueOnce({ + title: 'rebase!', + state: PrState.Open, + labels: ['stop-updating'], + bodyStruct: { hash: hashBody(`- [ ] <!-- rebase-check -->`) }, + } as Pr); + git.isBranchModified.mockResolvedValueOnce(true); + schedule.isScheduledNow.mockReturnValueOnce(false); + commit.commitFilesToBranch.mockResolvedValueOnce(null); + const inconfig = { + ...config, + dependencyDashboardChecks: { 'renovate/some-branch': 'true' }, + updatedArtifacts: [{ type: 'deletion', path: 'dummy' }], + } as BranchConfig; + expect(await branchWorker.processBranch(inconfig)).toEqual({ + branchExists: true, + prNo: undefined, + result: 'done', + commitSha: null, + }); + expect(commit.commitFilesToBranch).toHaveBeenCalled(); + }); + it('executes post-upgrade tasks if trust is high', async () => { const updatedPackageFile: FileChange = { type: 'addition', diff --git a/lib/workers/repository/update/branch/index.ts b/lib/workers/repository/update/branch/index.ts index d9d7082c49..a0692ecae0 100644 --- a/lib/workers/repository/update/branch/index.ts +++ b/lib/workers/repository/update/branch/index.ts @@ -489,7 +489,7 @@ export async function processBranch( const prRebaseChecked = !!branchPr?.bodyStruct?.rebaseRequested; - if (branchExists && dependencyDashboardCheck && config.stopUpdating) { + if (branchExists && !dependencyDashboardCheck && config.stopUpdating) { if (!prRebaseChecked) { logger.info( 'Branch updating is skipped because stopUpdatingLabel is present in config' -- GitLab