diff --git a/lib/util/git/index.spec.ts b/lib/util/git/index.spec.ts index b97aba5402c3c5..5043eec9f8bfea 100644 --- a/lib/util/git/index.spec.ts +++ b/lib/util/git/index.spec.ts @@ -424,6 +424,30 @@ describe('util/git/index', () => { const branches = await Git(origin.path).branch({}); expect(branches.all).not.toContain('renovate/past_branch'); }); + + it('should add no verify flag', async () => { + const rawSpy = jest.spyOn(SimpleGit.prototype, 'raw'); + await git.deleteBranch('renovate/something'); + expect(rawSpy).toHaveBeenCalledWith([ + 'push', + '--delete', + 'origin', + 'renovate/something', + ]); + }); + + it('should not add no verify flag', async () => { + const rawSpy = jest.spyOn(SimpleGit.prototype, 'raw'); + setNoVerify(['push']); + await git.deleteBranch('renovate/something'); + expect(rawSpy).toHaveBeenCalledWith([ + 'push', + '--delete', + 'origin', + 'renovate/something', + '--no-verify', + ]); + }); }); describe('getBranchLastCommitTime', () => { diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts index 5900222c072c11..49b48825697f07 100644 --- a/lib/util/git/index.ts +++ b/lib/util/git/index.ts @@ -767,7 +767,13 @@ export async function isBranchConflicted( export async function deleteBranch(branchName: string): Promise { await syncGit(); try { - await gitRetry(() => git.raw(['push', '--delete', 'origin', branchName])); + const deleteCommand = ['push', '--delete', 'origin', branchName]; + + if (getNoVerify().includes('push')) { + deleteCommand.push('--no-verify'); + } + + await gitRetry(() => git.raw(deleteCommand)); logger.debug(`Deleted remote branch: ${branchName}`); } catch (err) /* istanbul ignore next */ { const errChecked = checkForPlatformFailure(err);