mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
fix: don’t skip modified branch from old PR (#8885)
This commit is contained in:
parent
e136cd4424
commit
f3daa9e555
2 changed files with 39 additions and 2 deletions
|
@ -219,6 +219,22 @@ describe('workers/branch', () => {
|
||||||
const res = await branchWorker.processBranch(config);
|
const res = await branchWorker.processBranch(config);
|
||||||
expect(res).toEqual(ProcessBranchResult.PrEdited);
|
expect(res).toEqual(ProcessBranchResult.PrEdited);
|
||||||
});
|
});
|
||||||
|
it('continues branch if branch edited and but PR found', async () => {
|
||||||
|
git.branchExists.mockReturnValueOnce(true);
|
||||||
|
git.isBranchModified.mockResolvedValueOnce(true);
|
||||||
|
git.getBranchCommit.mockReturnValueOnce('abc123');
|
||||||
|
platform.findPr.mockResolvedValueOnce({ sha: 'abc123' } as any);
|
||||||
|
const res = await branchWorker.processBranch(config);
|
||||||
|
expect(res).toEqual(ProcessBranchResult.Error);
|
||||||
|
});
|
||||||
|
it('skips branch if branch edited and and PR found with sha mismatch', async () => {
|
||||||
|
git.branchExists.mockReturnValueOnce(true);
|
||||||
|
git.isBranchModified.mockResolvedValueOnce(true);
|
||||||
|
git.getBranchCommit.mockReturnValueOnce('abc123');
|
||||||
|
platform.findPr.mockResolvedValueOnce({ sha: 'def456' } as any);
|
||||||
|
const res = await branchWorker.processBranch(config);
|
||||||
|
expect(res).toEqual(ProcessBranchResult.PrEdited);
|
||||||
|
});
|
||||||
it('returns if branch creation limit exceeded', async () => {
|
it('returns if branch creation limit exceeded', async () => {
|
||||||
getUpdated.getUpdatedPackageFiles.mockResolvedValueOnce({
|
getUpdated.getUpdatedPackageFiles.mockResolvedValueOnce({
|
||||||
...updatedPackageFiles,
|
...updatedPackageFiles,
|
||||||
|
|
|
@ -25,6 +25,7 @@ import { readLocalFile, writeLocalFile } from '../../util/fs';
|
||||||
import {
|
import {
|
||||||
checkoutBranch,
|
checkoutBranch,
|
||||||
deleteBranch,
|
deleteBranch,
|
||||||
|
getBranchCommit,
|
||||||
getRepoStatus,
|
getRepoStatus,
|
||||||
branchExists as gitBranchExists,
|
branchExists as gitBranchExists,
|
||||||
isBranchModified,
|
isBranchModified,
|
||||||
|
@ -208,8 +209,28 @@ export async function processBranch(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (branchIsModified) {
|
} else if (branchIsModified) {
|
||||||
logger.debug('Branch has been edited');
|
const oldPr = await platform.findPr({
|
||||||
return ProcessBranchResult.PrEdited;
|
branchName: config.branchName,
|
||||||
|
state: PrState.NotOpen,
|
||||||
|
});
|
||||||
|
if (!oldPr) {
|
||||||
|
logger.debug('Branch has been edited but found no PR - skipping');
|
||||||
|
return ProcessBranchResult.PrEdited;
|
||||||
|
}
|
||||||
|
const branchSha = getBranchCommit(config.branchName);
|
||||||
|
const oldPrSha = oldPr?.sha;
|
||||||
|
if (!oldPrSha || oldPrSha === branchSha) {
|
||||||
|
logger.debug(
|
||||||
|
{ oldPrNumber: oldPr.number, oldPrSha, branchSha },
|
||||||
|
'Found old PR matching this branch - will override it'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
logger.debug(
|
||||||
|
{ oldPrNumber: oldPr.number, oldPrSha, branchSha },
|
||||||
|
'Found old PR but the SHA is different'
|
||||||
|
);
|
||||||
|
return ProcessBranchResult.PrEdited;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue