Skip to content

Commit

Permalink
fix(util/git): pass no-verify flag to deleteBranch (#29749)
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulGautamSingh committed Jun 18, 2024
1 parent 4a46ffd commit 4bc7414
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
24 changes: 24 additions & 0 deletions lib/util/git/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
8 changes: 7 additions & 1 deletion lib/util/git/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,13 @@ export async function isBranchConflicted(
export async function deleteBranch(branchName: string): Promise<void> {
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);
Expand Down

0 comments on commit 4bc7414

Please sign in to comment.