Gas waits for GitLab to compute mergeability instead of refusing. An unchecked (or checking/preparing/approvals_syncing) status now makes the Hub ask for a recheck as the merge account, every 30 seconds, and give up only after two minutes; lti-api !1384 was refused twice because nobody ever asked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 14:45:35 +07:00
parent f87272a3e4
commit 358a6ab304
3 changed files with 68 additions and 1 deletions

View File

@@ -307,6 +307,14 @@ export async function tokenCheck(kind: TokenKind, projects: string[]): Promise<{
export const botCheck = (projects: string[]) => tokenCheck('bot', projects);
// GitLab computes mergeability lazily and leaves it `unchecked` until someone asks; only a
// Developer or above may ask, so this runs as the merge account. The answer usually lands a
// few seconds later, so callers read the MR again on their next pass.
export async function recheckMergeStatus(ref: MrRef): Promise<string | null> {
const m = await tokenApi('merge', 'GET', `projects/${encodeURIComponent(ref.projectPath)}/merge_requests/${ref.iid}?with_merge_status_recheck=true`);
return m.detailed_merge_status ?? null;
}
// Merges exactly `sha`: GitLab refuses when the head moved, so Gas never merges an unreviewed commit.
export async function mergeMr(ref: MrRef, sha: string): Promise<{ mergeSha: string | null; state: string }> {
const m = await tokenApi('merge', 'PUT', `projects/${encodeURIComponent(ref.projectPath)}/merge_requests/${ref.iid}/merge`, { sha });