Skip to content

Commit

Permalink
fix(workers): Early return for rebaseWhen=never (#10424)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov committed Jun 18, 2021
1 parent c7c8ba9 commit 5f2e754
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
16 changes: 16 additions & 0 deletions lib/workers/branch/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type { EnsurePrResult } from '../pr';
import * as _prAutomerge from '../pr/automerge';
import type { Pr } from '../repository/onboarding/branch/check';
import type { BranchConfig, BranchUpgradeConfig } from '../types';
import { BranchResult } from '../types';
import * as _automerge from './automerge';
import * as _checkExisting from './check-existing';
import * as _commit from './commit';
Expand Down Expand Up @@ -1243,5 +1244,20 @@ describe(getName(), () => {
).toString()
).toBe('modified file content');
});
it('returns when rebaseWhen=never', async () => {
getUpdated.getUpdatedPackageFiles.mockResolvedValueOnce({
...updatedPackageFiles,
});
npmPostExtract.getAdditionalFiles.mockResolvedValueOnce({
artifactErrors: [],
updatedArtifacts: [],
});
git.branchExists.mockReturnValue(true);
commit.commitFilesToBranch.mockResolvedValueOnce(null);
expect(
await branchWorker.processBranch({ ...config, rebaseWhen: 'never' })
).toMatchObject({ result: BranchResult.NoWork });
expect(commit.commitFilesToBranch).not.toHaveBeenCalled();
});
});
});
14 changes: 10 additions & 4 deletions lib/workers/branch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,16 @@ export async function processBranch(
});
}
}
config.forceCommit =
!!dependencyDashboardCheck ||
config.rebaseRequested ||
branchPr?.isConflicted;
const forcedManually = !!dependencyDashboardCheck || config.rebaseRequested;
if (!forcedManually && config.rebaseWhen === 'never') {
logger.debug(`Skipping commit (rebaseWhen=never)`);
return {
branchExists,
prNo: branchPr?.number,
result: BranchResult.NoWork,
};
}
config.forceCommit = forcedManually || branchPr?.isConflicted;
const commitSha = await commitFilesToBranch(config);
// istanbul ignore if
if (branchPr && platform.refreshPr) {
Expand Down

0 comments on commit 5f2e754

Please sign in to comment.