Skip to content

Commit

Permalink
chore(gerrit): try auto-approve right before auto-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs committed Nov 30, 2024
1 parent 107a298 commit 6ac7b9e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/modules/platform/gerrit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,7 @@ export function findIssue(title: string): Promise<Issue | null> {
export function getIssueList(): Promise<Issue[]> {
return Promise.resolve([]);
}

export async function approvePr(number: number): Promise<void> {
await client.approveChange(number);
}
1 change: 1 addition & 0 deletions lib/modules/platform/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ export interface Platform {

maxBodyLength(): number;
labelCharLimit?(): number;
approvePr?(number: number): Promise<void>;
}

export interface PlatformScm {
Expand Down
6 changes: 6 additions & 0 deletions lib/workers/repository/update/pr/automerge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ export async function checkAutoMerge(
prAutomergeBlockReason: 'PlatformNotReady',
};
}
// Usually the PR will already be approved, this is a last resort in case the
// approval was lost for some reason
if (config.autoApprove && platform.approvePr) {
logger.debug('Auto-approving PR if needed before automerge');
await platform.approvePr(pr.number);
}
const branchStatus = await resolveBranchStatus(
branchName,
!!config.internalChecksAsSuccess,
Expand Down

0 comments on commit 6ac7b9e

Please sign in to comment.