Skip to content

Commit

Permalink
fix(repository/update): stopUpdating not working as expected (#17488)
Browse files Browse the repository at this point in the history
  • Loading branch information
henrist committed Aug 30, 2022
1 parent 548e0e5 commit 04ee279
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
37 changes: 36 additions & 1 deletion lib/workers/repository/update/branch/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/update/branch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 04ee279

Please sign in to comment.