Skip to content
Snippets Groups Projects
Commit 36e27922 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix(git): add branchExists safety check to isBranchModified

parent f0ba97b6
No related merge requests found
......@@ -136,6 +136,9 @@ describe('platform/git', () => {
});
});
describe('isBranchModified()', () => {
it('should return false when branch is not found', async () => {
expect(await git.isBranchModified('renovate/not_found')).toBe(false);
});
it('should return true when author matches', async () => {
expect(await git.isBranchModified('renovate/future_branch')).toBe(false);
expect(await git.isBranchModified('renovate/future_branch')).toBe(false);
......
......@@ -401,6 +401,13 @@ export async function isBranchModified(branchName: string): Promise<boolean> {
if (config.branchIsModified[branchName] !== undefined) {
return config.branchIsModified[branchName];
}
if (!branchExists(branchName)) {
logger.debug(
{ branchName },
'Branch does not exist - cannot check isModified'
);
return false;
}
// Retrieve the author of the most recent commit
const lastAuthor = (
await git.raw([
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment